The Biopython Seq object is basically an array, so you can specify its subsections and pass them to the new Seq object. Assuming you read them in seqrecord (dictionary) using the following code, you can simply specify the starting end position.
SeqRecords[Seq][start:end].seq
This will give you a SeqRecord sequence object between the start and end positions, which are integers. There is some kind of ridicule from the memory regarding indexing the beginning and the end, but play around to get this idea. You must also specify:
SeqRecords[Seq][:end].seq
To get the sequence from the beginning of SeqRecord.
For completeness, read in these files:
inputSeqFile = open(filename, "rU") SeqDict = SeqIO.to_dict(SeqIO.parse(inputSeqFile, "fasta")) inputSeqFile.close()
Hope this helps.
source share