import org.forester.io.parsers.phyloxml.PhyloXmlMapping;
import org.forester.io.parsers.phyloxml.PhyloXmlUtil;
import org.forester.io.writers.PhylogenyWriter;
+import org.forester.sequence.MolecularSequence;
+import org.forester.sequence.MolecularSequence.TYPE;
import org.forester.util.ForesterUtil;
public class Sequence implements PhylogenyData, MultipleUris, Comparable<Sequence> {
init();
}
+ public Sequence( final MolecularSequence mol_seq ) {
+ init();
+ setMolecularSequence( mol_seq.getMolecularSequenceAsString() );
+ setName( mol_seq.getIdentifier() );
+ String type;
+ if ( mol_seq.getType() == TYPE.AA ) {
+ type = "protein";
+ }
+ else if ( mol_seq.getType() == TYPE.DNA ) {
+ type = "dna";
+ }
+ else if ( mol_seq.getType() == TYPE.RNA ) {
+ type = "rna";
+ }
+ else {
+ throw new IllegalArgumentException( "unknown sequence type " + mol_seq.getType() );
+ }
+ try {
+ setType( type );
+ }
+ catch ( final PhyloXmlDataFormatException e ) {
+ throw new IllegalArgumentException( "don't know how to handle type " + mol_seq.getType() );
+ }
+ }
+
public void addAnnotation( final Annotation annotation ) {
getAnnotations().add( annotation );
}
/**
* Not a deep copy.
- *
+ *
*/
@Override
public PhylogenyData copy() {
annotation.toPhyloXML( writer, level, my_ind );
}
}
- if ( getDomainArchitecture() != null ) {
- getDomainArchitecture().toPhyloXML( writer, level, my_ind );
- }
if ( ( getCrossReferences() != null ) && !getCrossReferences().isEmpty() ) {
writer.write( ForesterUtil.LINE_SEPARATOR );
writer.write( my_ind );
writer.write( my_ind );
PhylogenyDataUtil.appendClose( writer, PhyloXmlMapping.SEQUENCE_X_REFS );
}
+ if ( getDomainArchitecture() != null ) {
+ getDomainArchitecture().toPhyloXML( writer, level, my_ind );
+ }
writer.write( ForesterUtil.LINE_SEPARATOR );
writer.write( indentation );
PhylogenyDataUtil.appendClose( writer, PhyloXmlMapping.SEQUENCE );