Mutable Seqrecords That Update Feature Locations Upon Insertion Or Deletion Of Bases?
2
0
Entering edit mode
11.5 years ago
BalderNGS • 0

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.0k views
ADD COMMENT
1
Entering edit mode
11.5 years ago
Peter 6.0k

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).

ADD COMMENT
0
Entering edit mode
11.5 years ago
BalderNGS • 0

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.

ADD COMMENT
0
Entering edit mode

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

ADD REPLY

Login before adding your answer.

Traffic: 2536 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6