| 107 | | dbxrefs = [] # TODO |
| | 117 | |
| | 118 | # TODO: remove from here !!!! |
| | 119 | def Sequences(self): |
| | 120 | ''' |
| | 121 | It tries to manage the storage of multiple sequences inside |
| | 122 | the seqrecord. It is able to manage 2 types of multiple sequence: |
| | 123 | - based on annotation-key: if in annotation key there is a key |
| | 124 | named multiple-sequences, and the key is a list of string, one for |
| | 125 | each sequence, where each string is of the type "label:start:end". |
| | 126 | - "label" that is the label of the sequence used also for |
| | 127 | the structure section (where the label is the chain) |
| | 128 | - "start" and "end" that are respectively the start and end |
| | 129 | position of each sequence inside the global sequence. |
| | 130 | - based on separator (a separator inside the sequence is used to |
| | 131 | separate the different sequences). It will use one of these |
| | 132 | three separators: "#", ",", ";" |
| | 133 | It returns a list of tuple, where each tuple is a 'label' and |
| | 134 | a seq object (Bio.Seq.Seq instance). |
| | 135 | ''' |
| | 136 | ##start to split on multiple-sequence annotation key |
| | 137 | seq = self.seqrecord.seq |
| | 138 | seq_list = [] |
| | 139 | if self.annotations.has_key('multiple-sequences'): |
| | 140 | for label_start_end in self.annotations['multiple-sequences']: |
| | 141 | label,start,end = label_start_end.split(':') |
| | 142 | subseq = BioSeq(seq.data[int(start):int(end)], alphabet = seq.alphabet) |
| | 143 | seq_list.append((label, subseq)) |
| | 144 | else: |
| | 145 | listsep = ['#',',',';'] |
| | 146 | separator = '' |
| | 147 | for sep in listsep: |
| | 148 | if seq.data.rfind(sep): separator = sep |
| | 149 | if separator: |
| | 150 | seqs = seq.data.split(separator) |
| | 151 | for seqdata in seqs: |
| | 152 | ## if separator is multiple... exclude '' objects |
| | 153 | if seqdata: |
| | 154 | subseq = BioSeq(seqdata, alphabet = seq.alphabet) |
| | 155 | seq_list.append(('',subseq)) |
| | 156 | ## if it didn't do any kind o split... return the whole seq |
| | 157 | if not seq_list: seq_list.append(('',seq)) |
| | 158 | return seq_list |