use of feast.nexus.CharactersBlock in project bacter by tgvaughan.
the class SimulatedAlignment method initAndValidate.
@Override
public void initAndValidate() {
acg = acgInput.get();
siteModel = siteModelInput.get();
Locus locus;
if (acg.getLoci().size() == 1)
locus = acg.getLoci().get(0);
else {
locus = locusInput.get();
if (locus == null)
throw new IllegalArgumentException("Must specify locus" + " when simulating alignment from ACG associated" + " with multiple loci.");
}
// We can't wait for Alignment.initAndValidate() to get the
// data type for us.
grabDataType();
// Simulate alignment
simulate(locus);
super.initAndValidate();
// Write simulated alignment to disk if requested:
if (outputFileNameInput.get() != null) {
try (PrintStream pstream = new PrintStream(outputFileNameInput.get())) {
if (useNexusInput.get()) {
NexusBuilder nb = new NexusBuilder();
nb.append(new TaxaBlock(acg.getTaxonset()));
nb.append(new CharactersBlock(this));
nb.write(pstream);
} else {
for (String taxonName : acg.getTaxaNames()) {
pstream.print(">" + taxonName + "\n");
pstream.print(getSequenceAsString(taxonName) + "\n");
}
}
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
}
Aggregations