问题描述
我正在尝试解析蛋白质 genbank
文件格式,这是一个示例文件 (example.protein.gpff
)
LOCUS NP_001346895 208 aa linear PRI 20-JAN-2018
DEFinitioN intercellular adhesion molecule 2 precursor [Cercocebus atys].
ACCESSION NP_001346895
VERSION NP_001346895.1
DBSOURCE REFSEQ: accession NM_001359966.1
KEYWORDS RefSeq.
SOURCE Cercocebus atys (sooty mangabey)
ORGANISM Cercocebus atys
Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi;
Mammalia; Eutheria; Euarchontoglires; Primates; Haplorrhini;
Catarrhini; Cercopithecidae; Cercopithecinae; Cercocebus.
REFERENCE 1 (residues 1 to 208)
AUTHORS Palesch D,Bosinger SE,Tharp GK,Vanderford TH,Paiardini M,Chahroudi A,Johnson ZP,Kirchhoff F,Hahn BH,norgren RB,Patel
NB,Sodora DL,Dawoud RA,Stewart CB,Seepo SM,Harris RA,Liu Y,Raveendran M,Han Y,English A,Thomas GWC,Hahn MW,Pipes L,Mason
CE,Muzny DM,Gibbs RA,Sauter D,Worley K,Rogers J and Silvestri
G.
TITLE Sooty mangabey genome sequence provides insight into AIDS
resistance in a natural SIV host
JOURNAL Nature 553 (7686),77-81 (2018)
PUBMED 29300007
COMMENT VALIDATED REFSEQ: This record has undergone validation or
preliminary review. The reference sequence was derived from
KY308194.1.
##Evidence-Data-START##
Transcript exon combination :: KY308194.1 [ECO:0000332]
RNAseq introns :: single sample supports all introns
SAMN02045730,SAMN03085078
[ECO:0000348]
##Evidence-Data-END##
FEATURES Location/Qualifiers
source 1..208
/organism="Cercocebus atys"
/db_xref="taxon:9531"
Protein 1..208
/product="intercellular adhesion molecule 2 precursor"
/calculated_mol_wt=21138
sig_peptide 1..19
/inference="COORDINATES: ab initio prediction:SignalP:4.0"
/calculated_mol_wt=1999
Region 24..109
/region_name="ICAM_N"
/note="Intercellular adhesion molecule (ICAM),N-terminal
domain; pfam03921"
/db_xref="CDD:252248"
Region 112..>167
/region_name="Ig"
/note="Immunoglobulin domain; cl11960"
/db_xref="CDD:325142"
CDS 1..208
/gene="ICAM2"
/coded_by="NM_001359966.1:1..627"
/db_xref="GeneID:105590766"
ORIGIN
1 mssfgfgtlt malfalvccs gsdekafevh mrleklivkp kesfevncst tcnqpevggl
61 etslnkilll eqtqwkhyli snishdtvlw chftcsgkqk smssnvsvyq pprqvfltlq
121 ptwvavgksf tiecrvpave pldsltlsll rgsetlhsqt frkaapalpv lrelgmkfiq
181 lcprrglagt mppsrpwcpa athwsqgc
//
LOCUS NP_001280013 406 aa linear MAM 22-JAN-2018
DEFinitioN 26S proteasome regulatory subunit 8 [Dasypus novemcinctus].
ACCESSION NP_001280013 XP_004456848
VERSION NP_001280013.1
DBSOURCE REFSEQ: accession NM_001293084.1
KEYWORDS RefSeq.
SOURCE Dasypus novemcinctus (nine-banded armadillo)
ORGANISM Dasypus novemcinctus
Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi;
Mammalia; Eutheria; Xenarthra; Cingulata; Dasypodidae; Dasypus.
COMMENT VALIDATED REFSEQ: This record has undergone validation or
preliminary review. The reference sequence was derived from
AAGV03083693.1.
On May 28,2014 this sequence version replaced XP_004456848.1.
Sequence Note: The RefSeq transcript and protein were derived from
genomic sequence to make the sequence consistent with the reference
genome assembly. The genomic coordinates used for the transcript
record were based on alignments.
##Evidence-Data-START##
RNAseq introns :: mixed/partial sample support SAMN00668203,SAMN00744121 [ECO:0000350]
##Evidence-Data-END##
FEATURES Location/Qualifiers
source 1..406
/organism="Dasypus novemcinctus"
/db_xref="taxon:9361"
Protein 1..406
/product="26S proteasome regulatory subunit 8"
/calculated_mol_wt=45495
Region 4..404
/region_name="RPT1"
/note="ATP-dependent 26S proteasome regulatory subunit
[Posttranslational modification,protein turnover,chaperones]; COG1222"
/db_xref="CDD:224143"
CDS 1..406
/gene="PSMC5"
/coded_by="NM_001293084.1:1..1221"
/db_xref="GeneID:101445299"
ORIGIN
1 maldgpeqme leegkagsgl rqyylskiee lqlivndksq nlrrlqaqrn elnakvrllr
61 eelqllqeqg syvgevvram dkkkvlvkvh pegkfvvdvd knidindvtp ncrvalrnds
121 ytlhkilpnk vdplvslmmv ekvpdstyem iggldkqike ikevielpvk hpelfealgi
181 aqpkgvllyg ppgtgktlla ravahhtdct firvsgselv qkfigegarm vrelfvmare
241 hapsiifmde idsigssrle ggsggdsevq rtmlellnql dgfeatknik vimatnridi
301 ldsallrpgr idrkiefppp neearldilk ihsrkmnltr ginlrkiael mpgasgaevk
361 gvcteagmya lrerrvhvtq edfemavakv mqkdseknms ikklwk
//
格式有重复的 record
(由 //
分隔),其中每个 record
是一个蛋白质。每个 record
都有几个部分,其中有一个 FEATURES
部分,其中有几个固定字段,例如 source
、CDS
和 Region
,其值是指信息特定于那个 record
。
我有兴趣使用 biopython
的 SeqIO
将此文件解析为 dataframe
,其中列出每个记录 ID、其 gene
的值、{ {1}} 和 db_xref
来自其 coded_by
字段,CDS
和 organism
值来自其 db_xref
字段,以及 source
值来自它的 db_xref
字段。除了 Region
字段可能在 Regions
的 FEATURES
部分出现多次外,record
和 CDS
字段在 source
中只出现一次FEATURES
的 {1}} 部分。
到目前为止,我失败的尝试是这样的:
record
我想获得的结果 from Bio import SeqIO
filename = "example.protein.gpff"
for record in SeqIO.parse(filename,"genbank"):
for feature in record.features:
if feature.type == "CDS":
symbol = feature.qualifiers.get("gene",["???"])[0]
gene_id = feature.qualifiers.get("db_xref",["???"])[0]
gene_id = re.sub('GeneID:','',gene_id)
transcript_id = feature.qualifiers.get("coded_by",["???"])[0]
transcript_id = re.sub(':.*',transcript_id)
if feature.type == "source":
species_name = feature.qualifiers.get("organism",["???"])[0]
species_id = feature.qualifiers.get("db_xref",["???"])[0]
species_id = re.sub('taxon:',species_id)
if feature.type == "Region":
cdd_id = feature.qualifiers.get("db_xref",["???"])[0]
cdd_id = re.sub('CDD:',cdd_id)
print("%s,%s,%s" % (record.id,cdd_id,transcript_id,symbol,gene_id,species_name,species_id))
(对于上面的 dataframe
)是:
example.protein.gpff