1 from obitools.seqdb import AnnotatedNucSequence, AnnotatedAASequence
2 from obitools.location import locationGenerator,extractExternalRefs
3
4
5
7 '''
8 Class used to represent a nucleic sequence issued from Genbank.
9 '''
10
11
13 '''
14 Class used to represent a peptidic sequence issued from Genpep.
15 '''
16
17 - def __init__(self,id,seq,de,header,featureTable,secondaryAcs,**info):
20
22 if self.__hasNucRef is None:
23 self.__hasNucRef=False
24 cds = [x for x in self.featureTable
25 if x.ftType=='CDS'
26 and 'coded_by' in x]
27
28 if cds:
29 source = cds[0]['coded_by'][0]
30 if 'transl_table' in cds[0]:
31 tt = cds[0]['transl_table'][0]
32 else:
33 tt=None
34 ac,loc = extractExternalRefs(source)
35
36 if len(ac)==1:
37 ac = ac.pop()
38 self.__hasNucRef=True
39 self.__nucRef = (ac,loc,tt)
40
41
42
44 '''
45 Predicat indicating if reference to the nucleic sequence encoding
46 this protein is available in feature table.
47
48 @return: True if gene description is available
49 @rtype: bool
50 '''
51 self.__getGeneRef()
52 return self.__hasNucRef is not None and self.__hasNucRef
53
54
56 '''
57 Return the nucleic sequence coding for this protein if
58 data are available.
59
60 @param database: a database object where looking for the sequence
61 @type database: a C{dict} like object
62
63 @return: a NucBioseq instance carreponding to the CDS
64 @rtype: NucBioSeq
65
66 @raise AssertionError: if no gene references are available
67 @see: L{geneAvailable}
68
69 '''
70
71 assert self.geneAvailable(), \
72 "No information available to retreive gene sequence"
73
74 ac,loc,tt = self.__nucRef
75 seq = database[ac]
76 seq.extractTaxon()
77 gene = seq[loc]
78 if tt is not None:
79 gene['transl_table']=tt
80 return gene
81