This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Mutable Seqrecords That Update Feature Locations Upon Insertion Or Deletion Of Bases?

I have a bunch of SeqRecords containing annotated scaffolds (contigs connected with N-stretches) I now have more accurate information on the length of the inserts and want to update the annotation as well.

I've been able to replace the sequence in a SeqRecord with a MutableSeq, enabling insertion or deletion or nucleotides, but (of course) that does not shift the features in the SeqRecord accordingly

before hacking something together, is there something like a MutableSeqRecord, that updates locations of features if you insert or delete bases?

biopython

2 answers

No there isn't a MutableSeqRecord, but to delete base 100 and preserve any features not spanning that base:

new = old[:100] + old[101:]

where 'old' is the original SeqRecord. Likewise to insert a base A at position 100, and preserve any features not spanning the insertion point you can do:

new = old[:100] + "A" + old[100:]

If there mutation is within a feature then these examples will discard the feature. In such cases you'd probably want to special case the feature handling anyway (e.g. consider frame-shifts).

Thanks. I didn't know that slicing a SeqRecord recalculated the positions. As there are no features within the scaffold n-stretches anyway it is safe to do.

Tip: You can comment on an answer (like this) rather than adding another answer.

Log in to answer this question.