def mga_summary(orf_fp, contigs_fp, sample_id):
"""Summarizes results from MetaGene Annotator."""
genes = []
gene_no = 0
contigs = SeqIO.parse(contigs_fp, 'fasta')
contig_seqs = {r.description: r.seq for r in contigs}
annotations = MetaGeneAnnotation.parse(open(orf_fp))
for anno in annotations:
contig_seq = contig_seqs[anno.id]
# Gather putative genes and create SeqRecords for them
for pgene in anno.genes:
gene_seq = contig_seq[pgene.start:pgene.end]
if pgene.strand == '-':
gene_seq = gene_seq.reverse_complement()
gene = SeqRecord(
gene_seq,
id=anno.id,
description="{}:{}".format(sample_id, gene_no))
genes.append(gene)
gene_no += 1
return genes
评论列表
文章目录