[Biopython-dev] [Bug 1944] New: Align.Generic adding iterator and
more
bugzilla-daemon at portal.open-bio.org
bugzilla-daemon at portal.open-bio.org
Fri Feb 3 14:13:05 EST 2006
http://bugzilla.open-bio.org/show_bug.cgi?id=1944
Summary: Align.Generic adding iterator and more
Product: Biopython
Version: Not Applicable
Platform: All
OS/Version: All
Status: NEW
Severity: enhancement
Priority: P2
Component: Main Distribution
AssignedTo: biopython-dev at biopython.org
ReportedBy: mcolosimo at mitre.org
I thought it would be nice to be able to directly iterate over the SeqRecords
in an alignment. So, I wrote it up and tested it with Bio.Clustalw. I also
added the ability to fill in other fields of the SeqRecord (similar to
Fasta.SequenceParser)
Diff below:
Index: Generic.py
===================================================================
RCS file: /home/repository/biopython/biopython/Bio/Align/Generic.py,v
retrieving revision 1.5
diff -r1.5 Generic.py
32c32
< # hold everything at a list of seq record objects
---
> # hold everything as a list of SeqRecord objects
33a34
> self._iter_pos = 0
34a36,51
> def __iter__(self):
> self.__iter_pos = 0
> return iter(self.next, None)
>
> def next(self):
> """Returns one sequence record at a time.
>
> @return: a SeqRecord or None if end of iteration.
> """
> if self._iter_pos >= len(self._records):
> return None
>
> rec = self._records[self._iter_pos]
> self._iter_pos += 1
> return rec
>
38c55,56
< The return value is a list of SeqRecord objects.
---
> @return: a list of the sequences.
> @rtype: SeqRecord
45,49c63,66
< Returns:
< o A Seq object for the requested sequence.
<
< Raises:
< o IndexError - If the specified number is out of range.
---
> @param number: the number of the sequence in the consensus.
> @return: the requested sequence.
> @rtype: SeqRecord.
> @raise IndexError: If the specified number is out of range.
69c86
< weight = 1.0):
---
> weight = 1.0, description2ids = None):
86a104,107
> o descriptor2id - A function that, when given the descriptor,
> will return the id, name, and description (in that order)
> for the record. If this is not given, then the entire descriptor
> line will be used as the description.
89c110,117
< new_record = SeqRecord(new_seq, description = descriptor)
---
> rec = SeqRecord(new_seq)
> if title2ids:
> seq_id, name, descr = title2ids(descriptor)
> rec.id = seq_id
> rec.name = name
> rec.description = descr
> else:
> rec.description = descriptor
99c127
< new_record.annotations['start'] = start
---
> rec.annotations['start'] = start
101c129
< new_record.annotations['end'] = end
---
> rec.annotations['end'] = end
104c132
< new_record.annotations['weight'] = weight
---
> rec.annotations['weight'] = weight
106c134,147
< self._records.append(new_record)
---
> # what happens if we're iterating?
> self._records.append(rec)
>
>
> def addSeqRecord(self, seqRec):
> """Add a Sequence Record to the Alignment
>
> @param seqRec: a sequence record (SeqRecord) to add.
> """
> if isinstance(seqRec, SeqRecord):
> self._records.append(seqRec)
> else:
> raise TypeError("sequence is NOT a SeqRecord Object")
>
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
More information about the Biopython-dev
mailing list