import org.forester.archaeopteryx.tools.Blast;
import org.forester.archaeopteryx.tools.ImageLoader;
import org.forester.io.parsers.phyloxml.PhyloXmlUtil;
+import org.forester.io.writers.SequenceWriter;
import org.forester.phylogeny.Phylogeny;
import org.forester.phylogeny.PhylogenyMethods;
import org.forester.phylogeny.PhylogenyMethods.DESCENDANT_SORT_PRIORITY;
StringBuilder sb = new StringBuilder();
if ( n.getNodeData().isHasSequence()
&& !ForesterUtil.isEmpty( n.getNodeData().getSequence().getMolecularSequence() ) ) {
- data.add( n.getNodeData().getSequence().getMolecularSequence() );
+ if ( !ForesterUtil.isEmpty( n.getNodeData().getSequence().getName() ) ) {
+ sb.append( SequenceWriter.toFasta( n.getNodeData().getSequence().getName(), n.getNodeData().getSequence().getMolecularSequence(), 60 ) );
+ }
+ else {
+ sb.append( SequenceWriter.toFasta( n.getName(), n.getNodeData().getSequence().getMolecularSequence(), 60 ) );
+
+ }
+ data.add( sb.toString() + "\n" );
}
break;
case SEQUENCE_ACC:
}
return sb;
}
+
+ public static StringBuilder toFasta( final String name, final String mol_seq, final int width ) {
+ final StringBuilder sb = new StringBuilder();
+ sb.append( ">" );
+ sb.append( name );
+ sb.append( ForesterUtil.LINE_SEPARATOR );
+ if ( ( width < 1 ) || ( width >= mol_seq.length() ) ) {
+ sb.append( mol_seq );
+ }
+ else {
+ final int lines = mol_seq.length() / width;
+ final int rest =mol_seq.length() - ( lines * width );
+ for( int i = 0; i < lines; ++i ) {
+ sb.append( mol_seq, i * width, width );
+ if ( i < ( lines - 1 ) ) {
+ sb.append( ForesterUtil.LINE_SEPARATOR );
+ }
+ }
+ if ( rest > 0 ) {
+ sb.append( ForesterUtil.LINE_SEPARATOR );
+ sb.append( mol_seq, lines * width, rest );
+ }
+ }
+ return sb;
+ }
public static void toFasta( final Sequence seq, final Writer w, final int width ) throws IOException {
w.write( ">" );