[Biojava-l] Getting a Slice of an Alignment
Dexter Riley
edbeaty at charter.net
Mon Jun 26 16:04:33 UTC 2006
I should have clarified; the >Seq1 lines were just to indicate that the
series of sequences were part of an alignment. I did a quick implementation
of what I was looking for, but was hoping that something like this already
existed, in a form that could handle gaps and alignment shifts properly :
public static Alignment getSlice(Alignment alignment, Location location)
throws BioException{
List<AlignmentElement> subAlignment = new ArrayList<AlignmentElement>();
List<String> labels = (List<String>) alignment.getLabels();
for (String label: labels){
subAlignment.add(new SimpleAlignmentElement(
label,
alignment.symbolListForLabel(label).subList(location.getMin(),
location.getMax()),
location)
);
}
return new FlexibleAlignment(subAlignment);
}
This implementation will probably not work as expected if the sequences
don't all begin at location 1. I'm honestly surprised that there's no
Alignment utility that will do something like this already; surely someone
else has had a need for a view to a part of an alignment before?
-Ed
--
View this message in context: http://www.nabble.com/Getting-a-Slice-of-an-Alignment-t1849222.html#a5049831
Sent from the BioJava forum at Nabble.com.
More information about the Biojava-l
mailing list