X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=forester%2Fjava%2Fsrc%2Forg%2Fforester%2Fmsa%2FBasicMsa.java;h=bf215d81bfbaac8c376180288cccf8a840e00a9c;hb=50c2ff100214fbb04b5f9665466e6d98d26b051d;hp=02da257664a0817e2a58a9a5a094e847a0dd8a99;hpb=917fdd32a745f77a8b70d7779e44b8b36e11185f;p=jalview.git diff --git a/forester/java/src/org/forester/msa/BasicMsa.java b/forester/java/src/org/forester/msa/BasicMsa.java index 02da257..bf215d8 100644 --- a/forester/java/src/org/forester/msa/BasicMsa.java +++ b/forester/java/src/org/forester/msa/BasicMsa.java @@ -143,7 +143,7 @@ public class BasicMsa implements Msa { } if ( _identifiers_set.contains( id ) ) { throw new IllegalArgumentException( "illegal attempt to create msa with non-unique identifiers [" + id - + "]" ); + + "]" ); } _identifiers_set.add( id ); _identifiers[ row ] = id; @@ -200,13 +200,32 @@ public class BasicMsa implements Msa { private void writeToNexus( final Writer w ) throws IOException { final int max = determineMaxIdLength() + 1; + TYPE t = null; + for( int row = 0; row < getNumberOfSequences(); ++row ) { + t = ForesterUtil.guessMolecularSequenceType( getSequence( row ).getMolecularSequenceAsString() ); + if ( t != null ) { + break; + } + } + String type_str = "Protein"; + if ( t != null ) { + if ( t == TYPE.DNA ) { + type_str = "DNA"; + } + else if ( t == TYPE.RNA ) { + type_str = "RNA"; + } + else if ( t == TYPE.GENERAL ) { + type_str = "Standard"; + } + } w.write( "Begin Data;" ); w.write( ForesterUtil.LINE_SEPARATOR ); w.write( " Dimensions NTax=" + getNumberOfSequences() ); w.write( " NChar=" + getLength() ); w.write( ";" ); w.write( ForesterUtil.LINE_SEPARATOR ); - w.write( " Format DataType=Protein Interleave=No gap=-;" ); + w.write( " Format DataType=" + type_str + " Interleave=No gap=-;" ); w.write( ForesterUtil.LINE_SEPARATOR ); w.write( " Matrix" ); w.write( ForesterUtil.LINE_SEPARATOR );