import org.forester.io.parsers.util.ParserUtils;
import org.forester.phylogeny.Phylogeny;
import org.forester.phylogeny.PhylogenyMethods;
+import org.forester.phylogeny.PhylogenyMethods.DESCENDANT_SORT_PRIORITY;
import org.forester.phylogeny.PhylogenyNode;
import org.forester.phylogeny.data.Accession;
import org.forester.phylogeny.data.BranchColor;
-import org.forester.phylogeny.data.Sequence;
import org.forester.phylogeny.data.Taxonomy;
import org.forester.phylogeny.factories.ParserBasedPhylogenyFactory;
import org.forester.phylogeny.factories.PhylogenyFactory;
final Configuration conf,
final TreePanel tp ) {
String uri_str = null;
- if ( node.getNodeData().isHasSequence() && ( node.getNodeData().getSequence().getAccession() != null )
- && !ForesterUtil.isEmpty( node.getNodeData().getSequence().getAccession().getSource() )
- && !ForesterUtil.isEmpty( node.getNodeData().getSequence().getAccession().getValue() )
- && conf.isHasWebLink( node.getNodeData().getSequence().getAccession().getSource().toLowerCase() ) ) {
- final Sequence seq = node.getNodeData().getSequence();
- final String source = seq.getAccession().getSource().toLowerCase();
- String url;
- if ( source.toLowerCase().equals( "ncbi" ) ) {
- url = Constants.NCBI_ALL_DATABASE_SEARCH;
- }
- else {
- final WebLink weblink = conf.getWebLink( source );
- url = weblink.getUrl().toString();
- }
+ final String upkb = ForesterUtil.extractUniProtKbProteinSeqIdentifier( node );
+ if ( !ForesterUtil.isEmpty( upkb ) ) {
try {
- uri_str = url + URLEncoder.encode( seq.getAccession().getValue(), ForesterConstants.UTF8 );
+ uri_str = ForesterUtil.UNIPROT_KB + URLEncoder.encode( upkb, ForesterConstants.UTF8 );
}
catch ( final UnsupportedEncodingException e ) {
showErrorMessage( tp, e.toString() );
}
}
if ( ForesterUtil.isEmpty( uri_str ) ) {
- final String upkb = ForesterUtil.extractUniProtKbProteinSeqIdentifier( node );
- if ( !ForesterUtil.isEmpty( upkb ) ) {
+ final String v = ForesterUtil.extractGenbankAccessor( node );
+ if ( !ForesterUtil.isEmpty( v ) ) {
try {
- uri_str = ForesterUtil.UNIPROT_KB + URLEncoder.encode( upkb, ForesterConstants.UTF8 );
+ if ( SequenceIdParser.isProtein( v ) ) {
+ uri_str = ForesterUtil.NCBI_PROTEIN + URLEncoder.encode( v, ForesterConstants.UTF8 );
+ }
+ else {
+ uri_str = ForesterUtil.NCBI_NUCCORE + URLEncoder.encode( v, ForesterConstants.UTF8 );
+ }
}
catch ( final UnsupportedEncodingException e ) {
showErrorMessage( tp, e.toString() );
}
}
if ( ForesterUtil.isEmpty( uri_str ) ) {
- final String v = ForesterUtil.extractGenbankAccessor( node );
+ final String v = ForesterUtil.extractRefSeqAccessorAccessor( node );
if ( !ForesterUtil.isEmpty( v ) ) {
try {
if ( SequenceIdParser.isProtein( v ) ) {
}
}
if ( ForesterUtil.isEmpty( uri_str ) ) {
- final String v = ForesterUtil.extractRefSeqAccessorAccessor( node );
+ final String v = ForesterUtil.extractGInumber( node );
if ( !ForesterUtil.isEmpty( v ) ) {
try {
- if ( SequenceIdParser.isProtein( v ) ) {
- uri_str = ForesterUtil.NCBI_PROTEIN + URLEncoder.encode( v, ForesterConstants.UTF8 );
- }
- else {
- uri_str = ForesterUtil.NCBI_NUCCORE + URLEncoder.encode( v, ForesterConstants.UTF8 );
- }
+ uri_str = ForesterUtil.NCBI_GI + URLEncoder.encode( v, ForesterConstants.UTF8 );
}
catch ( final UnsupportedEncodingException e ) {
showErrorMessage( tp, e.toString() );
final boolean phyloxml_validate_against_xsd,
final boolean replace_underscores,
final boolean internal_numbers_are_confidences,
- final TAXONOMY_EXTRACTION taxonomy_extraction )
- throws FileNotFoundException, IOException {
+ final TAXONOMY_EXTRACTION taxonomy_extraction,
+ final boolean midpoint_reroot ) throws FileNotFoundException,
+ IOException {
final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
final PhylogenyParser parser;
boolean nhx_or_nexus = false;
PhylogenyMethods.transferInternalNodeNamesToConfidence( phy );
}
}
+ if ( midpoint_reroot ) {
+ for( final Phylogeny phy : phys ) {
+ PhylogenyMethods.midpointRoot( phy );
+ PhylogenyMethods.orderAppearance( phy.getRoot(), true, true, DESCENDANT_SORT_PRIORITY.NODE_NAME );
+ }
+ }
return phys;
}