# How to isolate genes from whole genomes for phylogenetic tree analysis?

I have 446 whole Klebsiella Pneumoniae genomes I want to build a phylogenetic tree from. After reading about constructing phylogenetic trees it seems the only option for large numbers of genomes is to isolate a gene with low variability from generation to generation and use this gene to build a tree. For example Lars Jensen recommends using "16S rRNA [or] all ribosomal-protein-coding genes" https://www.biostars.org/p/1930/. What program isolates these genes of interest from the whole genome fasta files and can put them into a multiple alignment file? Or outputs them in a formate ready for a multiple alignment program such as Muave? The reason I say a multiple alignment file is because this it the type of file most phylogenetic tree programs take (I.E. clonalframe).

• Hi Daniel, I would be cautious to build a phylogeny on 16s rRNA sequences as informative variability is essentially nil. I would suggest a good starting point being concatenated MLST genes, and work from there. You have the whole genome seems wrong to focus on the least variable gene. Jul 5 '17 at 14:47
• Yes. Using 16S makes sense for distant species but not for closely related ones. it is extremely likely that there will be next to no variability at all. Jul 5 '17 at 15:15
• If you haven't yet annotated the genomes, do so with Prokka as suggested in some of the other answers. Once you've got that, you can easily pull gene features out of a genbank by name using biopython, once you've identified a few sequences you want to use as the basis for your sequence typing. Jul 5 '17 at 21:44

There are a lot of ways to do this. I suggest using Prokka/Roary to produce a core genome alignment. There's a useful tutorial on the Roary website:

for file in *
do
prokka --kingdom Bacteria --outdir "${file%%.*}" --genus Listeria --locustag "${file%%.*}" "$file" mv "${file%%.*}"/PROKKA_07052017.gff GFF/"{file%%.*}".gff # use current date done roary -f Alignment -e -n -v GFF/*.gff  Alignment/core_gene_alignment.aln can be used as input for phylogenetic analyses • Roary is my go to but you have no say in what come out in the alignment. If you want to select your gene content use blast as I suggest. Concatenate the output and use an alignment software. Jul 5 '17 at 15:02 • @terdon I added a code snippet to do the analysis. It can be used to isolate genes (plural). If the OP just wants to build a phylogenetic tree, there's no need to isolate specific genes. With almost 500 genomes from a single species there's unlikely to me much resolution from analyses of a single gene or from a handful of MLST genes. Jul 5 '17 at 20:39 Extract desired gene sequences using standalone blast Simply provide a reference database with your desired output. Set up your command and away you go. You can set the search up with a for loop for a batch of sequences. Command may look like for f in *.fasta; do f=(basename $f .fasta) blastn \ -outfmt "6 sseqid qseq %" \ -query$f.fasta \
-subject reference.fna \
> out/$f.fas done  Watch the output as blast will spit out the gene as detected in + or - sense. If you want to only gather positive sense use -strandoption. The default output I have here is tab output which requires a few sed commands to make into fasta. sed -i \ -e 's/\s*$//g' \
-e 's/^/>/g'  \
-e 's/\s\+/\n/g' \
*.fas


Online alignment servers are an easy way to align small datasets e.g. EBI

• It might be worth mentioning that this approach work for species with no splicing (so it should be fine for the OP), but isn't very useful for eukaryotic organisms. Also, why would you run multiple blasts in a loop like this? Why not give a multifasta input file to blast and run it once? Jul 5 '17 at 15:17
• Your query is the genome sequences you have \$f will insert the name for each in a loop. your desired gene sequences will be in your reference file. This could be the 16s or MLST gene sequences. Whatever you want to build a phylogeny of. Jul 5 '17 at 15:34
• A quick google brought this up bigsdb.pasteur.fr/klebsiella/klebsiella.html . Have a look about there is usually a file full of genes and alleles. In my experience one (allele) set of the 7 genes should suffice. Jul 5 '17 at 15:40
• @DanielHarris take one MLST gene and use that as a query to find the rest. Jul 5 '17 at 15:48
• @AudileF blast can take a multifasta file as a query and the results for each sequence in the input file will be shown in a separate Query= section. The names are indeed the names taken from the input file, but that shouldn't be a problem as long as they're all unique. Jul 5 '17 at 15:49