[Biojava-l] alignments
simon rayner
simon.rayner.cn at gmail.com
Sun Feb 8 09:45:46 UTC 2009
Hi,
i have a question about Alignment and FlexibleAlignment objects.
Basically, i have a sequence alignment in FASTA format so followed a code
sample i found from a previous posted query:
BufferedReader br = new BufferedReader(new FileReader("file.txt"));
FastaAlignmentFormat faf = new FastaAlignmentFormat();
Alignment aligned = faf.read( br );
so now i have an alignment stored in an Alignment object.
1. I do something with these sequences using the access methods for
the Alignment object.
something like
java.util.Iterator iter = l.listIterator();
while(iter.hasNext())
{
String currLabel = (String) iter.next();
String currAA
= aligned.symbolListForLabel(currLabel)
.seqString().substring(base, base+1);
}
2. Now i want to do the same analysis but on a random sample of
sequences from this alignment.
So to get a subset of these sequences i created a FlexibleAlignment
and grabbed the sequences
i need from the original alignment...
Alignment al;
Iterator l = al.symbolListIterator();
java.util.List<String> names = al.getLabels();
Iterator n = names.listIterator();
java.util.ArrayList seqList = new java.util.ArrayList(1);
String refs = "";
while(refs.length() < al.length())
{
refs = refs.concat("x");
}
try{
FlexibleAlignment FA = new FlexibleAlignment(seqList);
SymbolList aa = ProteinTools.createProtein(refs);
seqList.add(
new SimpleAlignmentElement(
"reference",
aa,
new RangeLocation(1, al.length()))
);
while (l.hasNext())
{
try{
SymbolList sal = (SymbolList)l.next();
String name = (String)n.next();
FA.addSequence(new SimpleAlignmentElement(name,
sal,
new RangeLocation(1, al.length())));
}
catch (org.biojava.bio.BioException ex)
{
System.out.print("couldn't add sequence to alignment\n");
System.err.print(ex);
}
}
this.aligned = FA;
}
catch (org.biojava.bio.BioException ex)
{
System.out.print("couldn't add sequence to alignment\n");
System.err.print(ex);
}
So now i have my alignment of random sequences in a FlexibleAlignment
object, but my original analysis
was written for an Alignment object (because that's the format that
FastaAlignmentFormat spat back at me.
So, can i cast a FlexibleAlignment object into an Alignment object? or
am i just going about it the wrong way?
p.s. Why are there so many diverse Alignment related objects?
(AbstractULAlignment,
AbstractULAlignment.SubULAlignment, FlexibleAlignment, RelabeledAlignment,
EmptyPairwiseAlignment, SimpleAlignment, HappyAlignment,
SadAlignment..) Is there any documentation (other than
the standard java docs) to clarify which object when?
thanks!
More information about the Biojava-l
mailing list