-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfind_gene.py
More file actions
25 lines (21 loc) · 786 Bytes
/
Copy pathfind_gene.py
File metadata and controls
25 lines (21 loc) · 786 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# -*- coding: utf-8 -*-
"""
Created on Wed May 8 17:19:43 2019
@author: Maria Pessoa Monteiro
"""
from Bio import SeqIO, Entrez
def find_gene(prot_acc):
"""
Find_gene accepts a protein AN as an argument. The function
returns the AN of the matching gene.
"""
results = []
prot_fetch = Entrez.efetch(db="protein", id=prot_acc, rettype="gb",
retmode="text")
record = SeqIO.read(prot_fetch, "gb")
for feat in record.features:
if feat.type == "CDS" and 'coded_by' in feat.qualifiers.keys():
gene_acc = str(feat.qualifiers['coded_by']).split(":")
gene_acc[0] = gene_acc[0].strip("[").strip("'")
results.append(f"DNA AN: {gene_acc[0]}")
return results