Getting underlying sequence from an ISequence

May 31, 2015 at 11:39 PM
When I do ISequence.ToString() it only gives me:
gactacacgtagtatGCTAGAATATCAAAAATTTTGGATTAAATTTTTATGTTAACTTTTATAG... +[868]
But how do I get the entire underlying sequence?
Coordinator
Jun 9, 2015 at 11:15 PM
Assuming you are using a concrete sequence class, use Sequence.ConvertToString(long startIndex,long length), which lets you specify the length to be extracted.
Jun 10, 2015 at 1:20 AM
I'm using the ISequence class but it doesn't have a ConvertToString(). Is there something else I should convert it to or are you saying I just need to write my own ConvertToString() method?
Coordinator
Jun 10, 2015 at 3:17 AM
Add "using Bio.Extensions" to your namespace. Then you'll have access to an extension method on any ISequence type. It's not exposed on the interface because some implementations can do it more efficiently than others and we didn't want to enforce a specific requirement to implement it on every concrete class.

The implementation is here:
https://bio.codeplex.com/SourceControl/latest#bio/Source/Framework/Bio.Core/Extensions/SequenceExtensions.cs

It's smart enough to look at the implementation and invoke the built-in (efficient) implementation if it exists, and if not, to copy the array over to a string.