From: cmzmasek@gmail.com Date: Sat, 23 Jun 2012 03:56:20 +0000 (+0000) Subject: in progress X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=e174d62534f7fc6f3de133d523a402a87735b27f;p=jalview.git in progress --- diff --git a/forester/java/src/org/forester/analysis/TaxonomyDataManager.java b/forester/java/src/org/forester/analysis/TaxonomyDataManager.java index 8f9dcc4..2534792 100644 --- a/forester/java/src/org/forester/analysis/TaxonomyDataManager.java +++ b/forester/java/src/org/forester/analysis/TaxonomyDataManager.java @@ -252,7 +252,7 @@ public final class TaxonomyDataManager extends RunnableProcess { not_found.add( tax.toString() ); } else { - not_found.add(node.getName() ); + not_found.add( node.getName() ); } if ( delete && node.isExternal() ) { not_found_external_nodes.add( node ); @@ -375,7 +375,8 @@ public final class TaxonomyDataManager extends RunnableProcess { synchronized final private static void updateTaxonomy( final QUERY_TYPE qt, final PhylogenyNode node, final Taxonomy tax, - final UniProtTaxonomy up_tax ) { + final UniProtTaxonomy up_tax ) + throws PhyloXmlDataFormatException { if ( ( qt != QUERY_TYPE.SN ) && !ForesterUtil.isEmpty( up_tax.getScientificName() ) && ForesterUtil.isEmpty( tax.getScientificName() ) ) { tax.setScientificName( up_tax.getScientificName() ); diff --git a/forester/java/src/org/forester/application/confadd.java b/forester/java/src/org/forester/application/confadd.java index db01fd4..fc4dd41 100644 --- a/forester/java/src/org/forester/application/confadd.java +++ b/forester/java/src/org/forester/application/confadd.java @@ -59,8 +59,13 @@ public class confadd { final static private String WWW = "www.phylosoft.org/forester/"; public static void main( final String args[] ) { - ForesterUtil.printProgramInformation( PRG_NAME, null, PRG_VERSION, PRG_DATE, E_MAIL, WWW, ForesterUtil.getForesterLibraryInformation() ); - + ForesterUtil.printProgramInformation( PRG_NAME, + null, + PRG_VERSION, + PRG_DATE, + E_MAIL, + WWW, + ForesterUtil.getForesterLibraryInformation() ); CommandLineArguments cla = null; try { cla = new CommandLineArguments( args ); diff --git a/forester/java/src/org/forester/application/count_support.java b/forester/java/src/org/forester/application/count_support.java index 96a7596..3096e21 100644 --- a/forester/java/src/org/forester/application/count_support.java +++ b/forester/java/src/org/forester/application/count_support.java @@ -50,13 +50,18 @@ public class count_support { final static private String PRG_NAME = "count_support"; final static private String PRG_VERSION = "1.0"; final static private String PRG_DATE = "2008.03.04"; - final static private String E_MAIL = "phylosoft@gmail.com"; - final static private String WWW = "www.phylosoft.org/forester/"; + final static private String E_MAIL = "phylosoft@gmail.com"; + final static private String WWW = "www.phylosoft.org/forester/"; private final static boolean WRITE_EVALUATORS_AS_NHX = false; public static void main( final String args[] ) { - ForesterUtil.printProgramInformation( PRG_NAME, null, PRG_VERSION, PRG_DATE, E_MAIL, WWW, ForesterUtil.getForesterLibraryInformation() ); - + ForesterUtil.printProgramInformation( PRG_NAME, + null, + PRG_VERSION, + PRG_DATE, + E_MAIL, + WWW, + ForesterUtil.getForesterLibraryInformation() ); if ( ( args.length < 3 ) || ( args.length > 7 ) ) { System.out.println(); System.out.println( count_support.PRG_NAME + ": wrong number of arguments" ); diff --git a/forester/java/src/org/forester/application/gene_tree_preprocess.java b/forester/java/src/org/forester/application/gene_tree_preprocess.java index 840c335..d1fd58e 100644 --- a/forester/java/src/org/forester/application/gene_tree_preprocess.java +++ b/forester/java/src/org/forester/application/gene_tree_preprocess.java @@ -82,7 +82,7 @@ public class gene_tree_preprocess { ForesterUtil.fatalError( PRG_NAME, "phylogeny has " + phy.getNumberOfExternalNodes() + " external node(s), aborting" ); } - final SortedSet not_found = SequenceDataRetriver.obtainSeqInformation( phy, true , false); + final SortedSet not_found = SequenceDataRetriver.obtainSeqInformation( phy, true, false ); for( final String remove_me : not_found ) { phy.deleteSubtree( phy.getNode( remove_me ), true ); } diff --git a/forester/java/src/org/forester/application/gsdi.java b/forester/java/src/org/forester/application/gsdi.java index de949a8..4b625cd 100644 --- a/forester/java/src/org/forester/application/gsdi.java +++ b/forester/java/src/org/forester/application/gsdi.java @@ -205,15 +205,18 @@ public final class gsdi { case SCIENTIFIC_NAME: PhylogenyMethods .transferNodeNameToField( species_tree, - PhylogenyMethods.PhylogenyNodeField.TAXONOMY_ID_UNIPROT_1 ); + PhylogenyMethods.PhylogenyNodeField.TAXONOMY_ID_UNIPROT_1, + true ); break; case CODE: PhylogenyMethods.transferNodeNameToField( species_tree, - PhylogenyMethods.PhylogenyNodeField.TAXONOMY_CODE ); + PhylogenyMethods.PhylogenyNodeField.TAXONOMY_CODE, + true ); break; case ID: PhylogenyMethods.transferNodeNameToField( species_tree, - PhylogenyMethods.PhylogenyNodeField.TAXONOMY_ID ); + PhylogenyMethods.PhylogenyNodeField.TAXONOMY_ID, + true ); break; default: ForesterUtil.fatalError( gsdi.PRG_NAME, "unable to determine comparison base" ); @@ -325,7 +328,7 @@ public final class gsdi { log_writer.println( "Number of duplications : " + sdi.getDuplicationsSum() ); if ( ( base_algorithm == BASE_ALGORITHM.GSDI ) ) { final GSDI gsdi = ( GSDI ) sdi; - File species_tree_used_file = new File( out_file + SUFFIX_FOR_SPECIES_TREE_USED ); + final File species_tree_used_file = new File( out_file + SUFFIX_FOR_SPECIES_TREE_USED ); try { final PhylogenyWriter writer = new PhylogenyWriter(); writer.toPhyloXML( species_tree_used_file, gsdi.getSpeciesTree(), 0 ); @@ -346,7 +349,7 @@ public final class gsdi { final int spec = gsdi.getSpeciationsSum(); System.out.println( "Number of speciations : " + spec ); log_writer.println( "Number of speciations : " + spec ); - for( PhylogenyNode n : gsdi.getMappedExternalSpeciesTreeNodes() ) { + for( final PhylogenyNode n : gsdi.getMappedExternalSpeciesTreeNodes() ) { System.out.println( n.toString() ); } } diff --git a/forester/java/src/org/forester/application/mcc.java b/forester/java/src/org/forester/application/mcc.java index e31679a..3ee440f 100644 --- a/forester/java/src/org/forester/application/mcc.java +++ b/forester/java/src/org/forester/application/mcc.java @@ -90,7 +90,13 @@ public class mcc { } private static void printHelp() { - ForesterUtil.printProgramInformation( PRG_NAME, PRG_DESC, PRG_VERSION, PRG_DATE, E_MAIL, WWW, ForesterUtil.getForesterLibraryInformation() ); + ForesterUtil.printProgramInformation( PRG_NAME, + PRG_DESC, + PRG_VERSION, + PRG_DATE, + E_MAIL, + WWW, + ForesterUtil.getForesterLibraryInformation() ); System.out.println( "Usage:" ); System.out.println(); System.out.println( PRG_NAME + " " ); diff --git a/forester/java/src/org/forester/application/phyloxml_converter.java b/forester/java/src/org/forester/application/phyloxml_converter.java index 6d45207..151072f 100644 --- a/forester/java/src/org/forester/application/phyloxml_converter.java +++ b/forester/java/src/org/forester/application/phyloxml_converter.java @@ -34,6 +34,7 @@ import java.util.List; import org.forester.io.parsers.PhylogenyParser; import org.forester.io.parsers.nexus.NexusPhylogeniesParser; import org.forester.io.parsers.nhx.NHXParser; +import org.forester.io.parsers.phyloxml.PhyloXmlDataFormatException; import org.forester.io.parsers.util.ParserUtils; import org.forester.io.writers.PhylogenyWriter; import org.forester.phylogeny.Phylogeny; @@ -74,7 +75,7 @@ public class phyloxml_converter { final static private String WWW = "www.phylosoft.org/forester/"; final static private boolean SPECIAL = false; - public static void main( final String args[] ) { + public static void main( final String args[] ) throws PhyloXmlDataFormatException { ForesterUtil.printProgramInformation( PRG_NAME, PRG_VERSION, PRG_DATE, E_MAIL, WWW ); CommandLineArguments cla = null; try { @@ -238,7 +239,7 @@ public class phyloxml_converter { } if ( field != null ) { for( final Phylogeny phy : phys ) { - PhylogenyMethods.transferNodeNameToField( phy, field ); + PhylogenyMethods.transferNodeNameToField( phy, field, false ); } } if ( midpoint_reroot ) { diff --git a/forester/java/src/org/forester/application/surfacing.java b/forester/java/src/org/forester/application/surfacing.java index a085c9d..692b699 100644 --- a/forester/java/src/org/forester/application/surfacing.java +++ b/forester/java/src/org/forester/application/surfacing.java @@ -2632,13 +2632,16 @@ public class surfacing { + ": to output binary domain combinations for (downstream) graph analysis" ); System.out.println( surfacing.OUTPUT_LIST_OF_ALL_PROTEINS_OPTIONS + ": to output all proteins per domain" ); System.out.println(); + System.out.println( "Example 1: java -Xms128m -Xmx512m -cp path/to/forester.jar" + + " org.forester.application.surfacing p2g=pfam2go_2012_02_07.txt -dufs -cos=Pfam_260_NC1" + + " -no_eo -mo=0 -input=genomes_limited.txt -out_dir=out -o=o " + + " -species_tree=tol.xml -obo=gene_ontology_2012_02_07.obo -pos_filter=f.txt -all_prot" ); System.out.println(); - System.out.println( "Example: java -Xms128m -Xmx512m -cp path/to/forester.jar" + System.out.println( "Example 2: java -Xms128m -Xmx512m -cp path/to/forester.jar" + " org.forester.application.surfacing -detail=punctilious -o=TEST.html -pwc=TEST" + " -cos=Pfam_ls_22_TC2 -p2g=pfam2go -obo=gene_ontology_edit.obo " + "-dc_sort=dom -ignore_with_self -no_singles -e=0.001 -mo=1 -no_eo " - + "-ds_output=detailed_html -scoring=domains -sort=alpha -" + JACKNIFE_OPTION - + "=50 human mouse brafl strpu" ); + + "-ds_output=detailed_html -scoring=domains -sort=alpha human mouse brafl strpu" ); System.out.println(); } diff --git a/forester/java/src/org/forester/archaeopteryx/AptxUtil.java b/forester/java/src/org/forester/archaeopteryx/AptxUtil.java index a2c4550..e355967 100644 --- a/forester/java/src/org/forester/archaeopteryx/AptxUtil.java +++ b/forester/java/src/org/forester/archaeopteryx/AptxUtil.java @@ -62,7 +62,6 @@ import javax.swing.JApplet; import javax.swing.JOptionPane; import javax.swing.text.MaskFormatter; -import org.forester.analysis.AncestralTaxonomyInference; import org.forester.analysis.TaxonomyDataManager; import org.forester.io.parsers.PhylogenyParser; import org.forester.io.parsers.phyloxml.PhyloXmlUtil; diff --git a/forester/java/src/org/forester/archaeopteryx/MainFrameApplication.java b/forester/java/src/org/forester/archaeopteryx/MainFrameApplication.java index 49ad580..1a113ab 100644 --- a/forester/java/src/org/forester/archaeopteryx/MainFrameApplication.java +++ b/forester/java/src/org/forester/archaeopteryx/MainFrameApplication.java @@ -78,6 +78,7 @@ import org.forester.io.parsers.GeneralMsaParser; import org.forester.io.parsers.PhylogenyParser; import org.forester.io.parsers.nexus.NexusPhylogeniesParser; import org.forester.io.parsers.nhx.NHXParser; +import org.forester.io.parsers.phyloxml.PhyloXmlDataFormatException; import org.forester.io.parsers.phyloxml.PhyloXmlParser; import org.forester.io.parsers.phyloxml.PhyloXmlUtil; import org.forester.io.parsers.tol.TolParser; @@ -1374,7 +1375,7 @@ public final class MainFrameApplication extends MainFrame { dispose(); } - private void extractTaxCodeFromNodeNames() { + private void extractTaxCodeFromNodeNames() throws PhyloXmlDataFormatException { if ( getCurrentTreePanel() != null ) { final Phylogeny phy = getCurrentTreePanel().getPhylogeny(); if ( ( phy != null ) && !phy.isEmpty() ) { @@ -1469,21 +1470,23 @@ public final class MainFrameApplication extends MainFrame { return false; } - private void moveNodeNamesToSeqNames() { + private void moveNodeNamesToSeqNames() throws PhyloXmlDataFormatException { if ( getCurrentTreePanel() != null ) { final Phylogeny phy = getCurrentTreePanel().getPhylogeny(); if ( ( phy != null ) && !phy.isEmpty() ) { - PhylogenyMethods.transferNodeNameToField( phy, PhylogenyMethods.PhylogenyNodeField.SEQUENCE_NAME ); + PhylogenyMethods + .transferNodeNameToField( phy, PhylogenyMethods.PhylogenyNodeField.SEQUENCE_NAME, false ); } } } - private void moveNodeNamesToTaxSn() { + private void moveNodeNamesToTaxSn() throws PhyloXmlDataFormatException { if ( getCurrentTreePanel() != null ) { final Phylogeny phy = getCurrentTreePanel().getPhylogeny(); if ( ( phy != null ) && !phy.isEmpty() ) { PhylogenyMethods.transferNodeNameToField( phy, - PhylogenyMethods.PhylogenyNodeField.TAXONOMY_SCIENTIFIC_NAME ); + PhylogenyMethods.PhylogenyNodeField.TAXONOMY_SCIENTIFIC_NAME, + false ); } } } diff --git a/forester/java/src/org/forester/archaeopteryx/TreePanel.java b/forester/java/src/org/forester/archaeopteryx/TreePanel.java index fa7484f..e857426 100644 --- a/forester/java/src/org/forester/archaeopteryx/TreePanel.java +++ b/forester/java/src/org/forester/archaeopteryx/TreePanel.java @@ -4546,11 +4546,9 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee } } if ( getMainPanel().getOptions().isAntialiasScreen() ) { - if ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR - && !getMainPanel().getOptions().isShowDefaultNodeShapes() - && ( getControlPanel() != null && !getControlPanel().isShowDomainArchitectures() ) - - ) { + if ( ( getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR ) + && !getMainPanel().getOptions().isShowDefaultNodeShapes() + && ( ( getControlPanel() != null ) && !getControlPanel().isShowDomainArchitectures() ) ) { _rendering_hints.put( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF ); } else { diff --git a/forester/java/src/org/forester/archaeopteryx/UrlTreeReader.java b/forester/java/src/org/forester/archaeopteryx/UrlTreeReader.java index 838ce62..f96864f 100644 --- a/forester/java/src/org/forester/archaeopteryx/UrlTreeReader.java +++ b/forester/java/src/org/forester/archaeopteryx/UrlTreeReader.java @@ -39,6 +39,7 @@ import org.forester.archaeopteryx.webservices.WebservicesManager; import org.forester.io.parsers.PhylogenyParser; import org.forester.io.parsers.nexus.NexusPhylogeniesParser; import org.forester.io.parsers.nhx.NHXParser; +import org.forester.io.parsers.phyloxml.PhyloXmlDataFormatException; import org.forester.io.parsers.phyloxml.PhyloXmlParser; import org.forester.io.parsers.tol.TolParser; import org.forester.phylogeny.Phylogeny; @@ -187,10 +188,26 @@ public class UrlTreeReader implements Runnable { PhylogenyMethods.transferInternalNodeNamesToConfidence( phylogeny ); } if ( client.getProcessingInstructions() != null ) { - WebserviceUtil.processInstructions( client, phylogeny ); + try { + WebserviceUtil.processInstructions( client, phylogeny ); + } + catch ( final PhyloXmlDataFormatException e ) { + JOptionPane.showMessageDialog( _main_frame, + "Error:\n" + e.getLocalizedMessage(), + "Error", + JOptionPane.ERROR_MESSAGE ); + } } if ( client.getNodeField() != null ) { - PhylogenyMethods.transferNodeNameToField( phylogeny, client.getNodeField() ); + try { + PhylogenyMethods.transferNodeNameToField( phylogeny, client.getNodeField(), false ); + } + catch ( final PhyloXmlDataFormatException e ) { + JOptionPane.showMessageDialog( _main_frame, + "Error:\n" + e.getLocalizedMessage(), + "Error", + JOptionPane.ERROR_MESSAGE ); + } } phylogeny.setIdentifier( new Identifier( identifier, client.getName() ) ); _main_frame.getJMenuBar().remove( _main_frame.getHelpMenu() ); diff --git a/forester/java/src/org/forester/archaeopteryx/tools/RunnableProcess.java b/forester/java/src/org/forester/archaeopteryx/tools/RunnableProcess.java index 0453946..9fe35fa 100644 --- a/forester/java/src/org/forester/archaeopteryx/tools/RunnableProcess.java +++ b/forester/java/src/org/forester/archaeopteryx/tools/RunnableProcess.java @@ -17,7 +17,7 @@ public abstract class RunnableProcess implements Runnable { _process_id = process_id; } - public void start( final MainFrame mf, final String name ) { + public void start( final MainFrame mf, final String name ) { setProcessId( mf.getProcessPool().addProcess( name ) ); mf.updateProcessMenu(); } diff --git a/forester/java/src/org/forester/archaeopteryx/tools/SequenceDataRetriver.java b/forester/java/src/org/forester/archaeopteryx/tools/SequenceDataRetriver.java index 7c6291d..3f4ddda 100644 --- a/forester/java/src/org/forester/archaeopteryx/tools/SequenceDataRetriver.java +++ b/forester/java/src/org/forester/archaeopteryx/tools/SequenceDataRetriver.java @@ -142,7 +142,8 @@ public final class SequenceDataRetriver extends RunnableProcess { } } - public static SortedSet obtainSeqInformation( final Phylogeny phy, final boolean ext_nodes_only, + public static SortedSet obtainSeqInformation( final Phylogeny phy, + final boolean ext_nodes_only, final boolean allow_to_set_taxonomic_data ) throws IOException { final SortedSet not_found = new TreeSet(); diff --git a/forester/java/src/org/forester/archaeopteryx/webservices/WebserviceUtil.java b/forester/java/src/org/forester/archaeopteryx/webservices/WebserviceUtil.java index 71c047a..86ff0d6 100644 --- a/forester/java/src/org/forester/archaeopteryx/webservices/WebserviceUtil.java +++ b/forester/java/src/org/forester/archaeopteryx/webservices/WebserviceUtil.java @@ -28,6 +28,7 @@ import java.util.ArrayList; import java.util.List; import org.forester.archaeopteryx.webservices.WebservicesManager.WsPhylogenyFormat; +import org.forester.io.parsers.phyloxml.PhyloXmlDataFormatException; import org.forester.io.parsers.phyloxml.PhyloXmlUtil; import org.forester.phylogeny.Phylogeny; import org.forester.phylogeny.PhylogenyMethods; @@ -135,7 +136,8 @@ public final class WebserviceUtil { } } - public static void processInstructions( final PhylogeniesWebserviceClient client, final Phylogeny phylogeny ) { + public static void processInstructions( final PhylogeniesWebserviceClient client, final Phylogeny phylogeny ) + throws PhyloXmlDataFormatException { if ( client.getProcessingInstructions().equals( WebserviceUtil.TAX_CODE_TO_SCI_NAME ) ) { WebserviceUtil.transferTaxonomyCodeToScientificName( phylogeny ); } @@ -162,7 +164,7 @@ public final class WebserviceUtil { } } - static void transferExternalScientificNameToTaxonomyCode( final Phylogeny phy ) { + static void transferExternalScientificNameToTaxonomyCode( final Phylogeny phy ) throws PhyloXmlDataFormatException { final PhylogenyNodeIterator it = phy.iteratorPostorder(); while ( it.hasNext() ) { final PhylogenyNode n = it.next(); @@ -176,7 +178,7 @@ public final class WebserviceUtil { } } - static void transferInternalTaxonomyCodeToScientificName( final Phylogeny phy ) { + static void transferInternalTaxonomyCodeToScientificName( final Phylogeny phy ) throws PhyloXmlDataFormatException { final PhylogenyNodeIterator it = phy.iteratorPostorder(); while ( it.hasNext() ) { final PhylogenyNode n = it.next(); @@ -204,7 +206,7 @@ public final class WebserviceUtil { } } - static void transferTaxonomyCodeToScientificName( final Phylogeny phy ) { + static void transferTaxonomyCodeToScientificName( final Phylogeny phy ) throws PhyloXmlDataFormatException { final PhylogenyNodeIterator it = phy.iteratorPostorder(); while ( it.hasNext() ) { final PhylogenyNode n = it.next(); diff --git a/forester/java/src/org/forester/development/DevelopmentTools.java b/forester/java/src/org/forester/development/DevelopmentTools.java index 9cb5e77..8cc0cc5 100644 --- a/forester/java/src/org/forester/development/DevelopmentTools.java +++ b/forester/java/src/org/forester/development/DevelopmentTools.java @@ -27,6 +27,7 @@ package org.forester.development; import java.util.Random; +import org.forester.io.parsers.phyloxml.PhyloXmlDataFormatException; import org.forester.phylogeny.Phylogeny; import org.forester.phylogeny.PhylogenyMethods; import org.forester.phylogeny.PhylogenyNode; @@ -133,7 +134,12 @@ public final class DevelopmentTools { PhylogenyNode n = t.getFirstExternalNode(); int j = t.getRoot().getNumberOfExternalNodes(); while ( n != null ) { - PhylogenyMethods.setTaxonomyCode( n, j + "" ); + try { + PhylogenyMethods.setTaxonomyCode( n, j + "" ); + } + catch ( final PhyloXmlDataFormatException e ) { + e.printStackTrace(); + } j--; n = n.getNextExternalNode(); } @@ -177,7 +183,12 @@ public final class DevelopmentTools { PhylogenyNode n = t.getFirstExternalNode(); while ( n != null ) { final String code = ( ( Math.abs( r.nextInt() ) % ( ma - mi + 1 ) ) + mi ) + ""; - PhylogenyMethods.setTaxonomyCode( n, code ); + try { + PhylogenyMethods.setTaxonomyCode( n, code ); + } + catch ( final PhyloXmlDataFormatException e ) { + e.printStackTrace(); + } n = n.getNextExternalNode(); } } diff --git a/forester/java/src/org/forester/io/parsers/nhx/NHXParser.java b/forester/java/src/org/forester/io/parsers/nhx/NHXParser.java index c373104..f03ed69 100644 --- a/forester/java/src/org/forester/io/parsers/nhx/NHXParser.java +++ b/forester/java/src/org/forester/io/parsers/nhx/NHXParser.java @@ -39,6 +39,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import org.forester.io.parsers.PhylogenyParser; +import org.forester.io.parsers.phyloxml.PhyloXmlDataFormatException; import org.forester.io.parsers.util.ParserUtils; import org.forester.io.parsers.util.PhylogenyParserException; import org.forester.phylogeny.Phylogeny; @@ -118,8 +119,9 @@ public final class NHXParser implements PhylogenyParser { * * @throws PhylogenyParserException * @throws NHXFormatException + * @throws PhyloXmlDataFormatException */ - private void finishPhylogeny() throws PhylogenyParserException, NHXFormatException { + private void finishPhylogeny() throws PhylogenyParserException, NHXFormatException, PhyloXmlDataFormatException { setCladeLevel( 0 ); if ( getCurrentPhylogeny() != null ) { parseNHX( getCurrentAnotation().toString(), @@ -142,7 +144,8 @@ public final class NHXParser implements PhylogenyParser { } } - private void finishSingleNodePhylogeny() throws PhylogenyParserException, NHXFormatException { + private void finishSingleNodePhylogeny() throws PhylogenyParserException, NHXFormatException, + PhyloXmlDataFormatException { setCladeLevel( 0 ); final PhylogenyNode new_node = new PhylogenyNode(); parseNHX( getCurrentAnotation().toString(), new_node, getTaxonomyExtraction(), isReplaceUnderscores() ); @@ -408,8 +411,9 @@ public final class NHXParser implements PhylogenyParser { * * @throws PhylogenyParserException * @throws NHXFormatException + * @throws PhyloXmlDataFormatException */ - private void processCloseParen() throws PhylogenyParserException, NHXFormatException { + private void processCloseParen() throws PhylogenyParserException, NHXFormatException, PhyloXmlDataFormatException { decreaseCladeLevel(); if ( !isSawClosingParen() ) { final PhylogenyNode new_node = new PhylogenyNode(); @@ -435,8 +439,9 @@ public final class NHXParser implements PhylogenyParser { * * @throws PhylogenyParserException * @throws NHXFormatException + * @throws PhyloXmlDataFormatException */ - private void processComma() throws PhylogenyParserException, NHXFormatException { + private void processComma() throws PhylogenyParserException, NHXFormatException, PhyloXmlDataFormatException { if ( !isSawClosingParen() ) { final PhylogenyNode new_node = new PhylogenyNode(); parseNHX( getCurrentAnotation().toString(), new_node, getTaxonomyExtraction(), isReplaceUnderscores() ); @@ -460,8 +465,9 @@ public final class NHXParser implements PhylogenyParser { * * @throws PhylogenyParserException * @throws NHXFormatException + * @throws PhyloXmlDataFormatException */ - private void processOpenParen() throws PhylogenyParserException, NHXFormatException { + private void processOpenParen() throws PhylogenyParserException, NHXFormatException, PhyloXmlDataFormatException { final PhylogenyNode new_node = new PhylogenyNode(); if ( getCladeLevel() == 0 ) { if ( getCurrentPhylogeny() != null ) { @@ -643,7 +649,8 @@ public final class NHXParser implements PhylogenyParser { public static void parseNHX( String s, final PhylogenyNode node_to_annotate, final PhylogenyMethods.TAXONOMY_EXTRACTION taxonomy_extraction, - final boolean replace_underscores ) throws NHXFormatException { + final boolean replace_underscores ) throws NHXFormatException, + PhyloXmlDataFormatException { if ( ( taxonomy_extraction != PhylogenyMethods.TAXONOMY_EXTRACTION.NO ) && replace_underscores ) { throw new IllegalArgumentException( "cannot extract taxonomies and replace under scores at the same time" ); } diff --git a/forester/java/src/org/forester/io/parsers/phyloxml/PhyloXmlDataFormatException.java b/forester/java/src/org/forester/io/parsers/phyloxml/PhyloXmlDataFormatException.java index e53bf71..5dcd5a8 100644 --- a/forester/java/src/org/forester/io/parsers/phyloxml/PhyloXmlDataFormatException.java +++ b/forester/java/src/org/forester/io/parsers/phyloxml/PhyloXmlDataFormatException.java @@ -26,7 +26,9 @@ package org.forester.io.parsers.phyloxml; -public class PhyloXmlDataFormatException extends PhyloXmlException { +import java.io.IOException; + +public class PhyloXmlDataFormatException extends IOException { private static final long serialVersionUID = 3756209394438250170L; diff --git a/forester/java/src/org/forester/io/parsers/phyloxml/PhyloXmlHandler.java b/forester/java/src/org/forester/io/parsers/phyloxml/PhyloXmlHandler.java index c4c5be2..b724a79 100644 --- a/forester/java/src/org/forester/io/parsers/phyloxml/PhyloXmlHandler.java +++ b/forester/java/src/org/forester/io/parsers/phyloxml/PhyloXmlHandler.java @@ -120,6 +120,9 @@ public final class PhyloXmlHandler extends DefaultHandler { catch ( final PhylogenyParserException ex ) { throw new SAXException( ex.getMessage() ); } + catch ( final PhyloXmlDataFormatException e ) { + throw new SAXException( e.getMessage() ); + } } else if ( local_name.equals( PhyloXmlMapping.SEQUENCE_RELATION ) ) { try { @@ -173,7 +176,7 @@ public final class PhyloXmlHandler extends DefaultHandler { } } } - catch ( final PhylogenyParserException ex ) { + catch ( final PhyloXmlDataFormatException ex ) { throw new SAXException( ex.getMessage() ); } } @@ -181,8 +184,11 @@ public final class PhyloXmlHandler extends DefaultHandler { try { PhyloXmlHandler.mapElementToPhylogeny( getCurrentXmlElement(), getCurrentPhylogeny() ); } - catch ( final PhylogenyParserException ex ) { - throw new SAXException( ex.getMessage() ); + catch ( final PhylogenyParserException e ) { + throw new SAXException( e.getMessage() ); + } + catch ( final PhyloXmlDataFormatException e ) { + throw new SAXException( e.getMessage() ); } finishPhylogeny(); reset(); @@ -245,7 +251,7 @@ public final class PhyloXmlHandler extends DefaultHandler { } private void mapElementToPhylogenyNode( final XmlElement xml_element, final PhylogenyNode node ) - throws PhylogenyParserException { + throws PhylogenyParserException, PhyloXmlDataFormatException { if ( xml_element.isHasAttribute( PhyloXmlMapping.BRANCH_LENGTH ) ) { double d = 0; try { @@ -440,7 +446,7 @@ public final class PhyloXmlHandler extends DefaultHandler { } private static void mapElementToPhylogeny( final XmlElement xml_element, final Phylogeny phylogeny ) - throws PhylogenyParserException { + throws PhylogenyParserException, PhyloXmlDataFormatException { for( int i = 0; i < xml_element.getNumberOfChildElements(); ++i ) { final XmlElement element = xml_element.getChildElement( i ); final String qualified_name = element.getQualifiedName(); diff --git a/forester/java/src/org/forester/io/parsers/phyloxml/XmlElement.java b/forester/java/src/org/forester/io/parsers/phyloxml/XmlElement.java index beea81d..27df49c 100644 --- a/forester/java/src/org/forester/io/parsers/phyloxml/XmlElement.java +++ b/forester/java/src/org/forester/io/parsers/phyloxml/XmlElement.java @@ -136,25 +136,25 @@ public class XmlElement { return b; } - public double getValueAsDouble() throws PhylogenyParserException { + public double getValueAsDouble() throws PhyloXmlDataFormatException { double d = 0.0; try { d = Double.parseDouble( getValueAsString() ); } catch ( final NumberFormatException ex ) { - throw new PhylogenyParserException( "attempt to parse [" + getValueAsString() + "] into double, in " + throw new PhyloXmlDataFormatException( "attempt to parse [" + getValueAsString() + "] into double, in " + toString() ); } return d; } - public int getValueAsInt() throws PhylogenyParserException { + public int getValueAsInt() throws PhyloXmlDataFormatException { int i = 0; try { i = Integer.parseInt( getValueAsString() ); } catch ( final NumberFormatException ex ) { - throw new PhylogenyParserException( "attempt to parse [" + getValueAsString() + "] into integer, in " + throw new PhyloXmlDataFormatException( "attempt to parse [" + getValueAsString() + "] into integer, in " + toString() ); } return i; diff --git a/forester/java/src/org/forester/io/parsers/phyloxml/data/AccessionParser.java b/forester/java/src/org/forester/io/parsers/phyloxml/data/AccessionParser.java index e5e5947..e70b11c 100644 --- a/forester/java/src/org/forester/io/parsers/phyloxml/data/AccessionParser.java +++ b/forester/java/src/org/forester/io/parsers/phyloxml/data/AccessionParser.java @@ -25,9 +25,9 @@ package org.forester.io.parsers.phyloxml.data; +import org.forester.io.parsers.phyloxml.PhyloXmlDataFormatException; import org.forester.io.parsers.phyloxml.PhyloXmlMapping; import org.forester.io.parsers.phyloxml.XmlElement; -import org.forester.io.parsers.util.PhylogenyParserException; import org.forester.phylogeny.data.Accession; import org.forester.phylogeny.data.PhylogenyData; @@ -47,7 +47,7 @@ public class AccessionParser implements PhylogenyDataPhyloXmlParser { } @Override - public PhylogenyData parse( final XmlElement element ) throws PhylogenyParserException { + public PhylogenyData parse( final XmlElement element ) throws PhyloXmlDataFormatException { if ( element.isHasAttribute( PhyloXmlMapping.ACCESSION_SOURCE_ATTR ) ) { return new Accession( element.getValueAsString(), element.getAttribute( PhyloXmlMapping.ACCESSION_SOURCE_ATTR ) ); diff --git a/forester/java/src/org/forester/io/parsers/phyloxml/data/AnnotationParser.java b/forester/java/src/org/forester/io/parsers/phyloxml/data/AnnotationParser.java index 00494f5..c878170 100644 --- a/forester/java/src/org/forester/io/parsers/phyloxml/data/AnnotationParser.java +++ b/forester/java/src/org/forester/io/parsers/phyloxml/data/AnnotationParser.java @@ -25,9 +25,9 @@ package org.forester.io.parsers.phyloxml.data; +import org.forester.io.parsers.phyloxml.PhyloXmlDataFormatException; import org.forester.io.parsers.phyloxml.PhyloXmlMapping; import org.forester.io.parsers.phyloxml.XmlElement; -import org.forester.io.parsers.util.PhylogenyParserException; import org.forester.phylogeny.data.Annotation; import org.forester.phylogeny.data.Confidence; import org.forester.phylogeny.data.PhylogenyData; @@ -51,7 +51,7 @@ public class AnnotationParser implements PhylogenyDataPhyloXmlParser { } @Override - public PhylogenyData parse( final XmlElement element ) throws PhylogenyParserException { + public PhylogenyData parse( final XmlElement element ) throws PhyloXmlDataFormatException { String ref; if ( element.isHasAttribute( PhyloXmlMapping.ANNOTATION_REF_ATTR ) ) { ref = element.getAttribute( PhyloXmlMapping.ANNOTATION_REF_ATTR ); diff --git a/forester/java/src/org/forester/io/parsers/phyloxml/data/BinaryCharactersParser.java b/forester/java/src/org/forester/io/parsers/phyloxml/data/BinaryCharactersParser.java index dbd402e..1d22594 100644 --- a/forester/java/src/org/forester/io/parsers/phyloxml/data/BinaryCharactersParser.java +++ b/forester/java/src/org/forester/io/parsers/phyloxml/data/BinaryCharactersParser.java @@ -28,9 +28,9 @@ package org.forester.io.parsers.phyloxml.data; import java.util.SortedSet; import java.util.TreeSet; +import org.forester.io.parsers.phyloxml.PhyloXmlDataFormatException; import org.forester.io.parsers.phyloxml.PhyloXmlMapping; import org.forester.io.parsers.phyloxml.XmlElement; -import org.forester.io.parsers.util.PhylogenyParserException; import org.forester.phylogeny.data.BinaryCharacters; import org.forester.phylogeny.data.PhylogenyData; @@ -50,7 +50,7 @@ public class BinaryCharactersParser implements PhylogenyDataPhyloXmlParser { } @Override - public PhylogenyData parse( final XmlElement element ) throws PhylogenyParserException { + public PhylogenyData parse( final XmlElement element ) throws PhyloXmlDataFormatException { final SortedSet present = new TreeSet(); final SortedSet gained = new TreeSet(); final SortedSet lost = new TreeSet(); @@ -76,7 +76,7 @@ public class BinaryCharactersParser implements PhylogenyDataPhyloXmlParser { } } catch ( final NumberFormatException e ) { - throw new PhylogenyParserException( "failed to parse integer from element " + element.getQualifiedName() ); + throw new PhyloXmlDataFormatException( "failed to parse integer from element " + element.getQualifiedName() ); } for( int i = 0; i < element.getNumberOfChildElements(); ++i ) { final XmlElement child_element = element.getChildElement( i ); diff --git a/forester/java/src/org/forester/io/parsers/phyloxml/data/BranchWidthParser.java b/forester/java/src/org/forester/io/parsers/phyloxml/data/BranchWidthParser.java index c607603..05f08d7 100644 --- a/forester/java/src/org/forester/io/parsers/phyloxml/data/BranchWidthParser.java +++ b/forester/java/src/org/forester/io/parsers/phyloxml/data/BranchWidthParser.java @@ -25,8 +25,8 @@ package org.forester.io.parsers.phyloxml.data; +import org.forester.io.parsers.phyloxml.PhyloXmlDataFormatException; import org.forester.io.parsers.phyloxml.XmlElement; -import org.forester.io.parsers.util.PhylogenyParserException; import org.forester.phylogeny.data.BranchWidth; import org.forester.phylogeny.data.PhylogenyData; @@ -46,7 +46,7 @@ public class BranchWidthParser implements PhylogenyDataPhyloXmlParser { } @Override - public PhylogenyData parse( final XmlElement element ) throws PhylogenyParserException { + public PhylogenyData parse( final XmlElement element ) throws PhyloXmlDataFormatException { return new BranchWidth( element.getValueAsDouble() ); } diff --git a/forester/java/src/org/forester/io/parsers/phyloxml/data/ColorParser.java b/forester/java/src/org/forester/io/parsers/phyloxml/data/ColorParser.java index 6d27c65..fa4a661 100644 --- a/forester/java/src/org/forester/io/parsers/phyloxml/data/ColorParser.java +++ b/forester/java/src/org/forester/io/parsers/phyloxml/data/ColorParser.java @@ -27,9 +27,9 @@ package org.forester.io.parsers.phyloxml.data; import java.awt.Color; +import org.forester.io.parsers.phyloxml.PhyloXmlDataFormatException; import org.forester.io.parsers.phyloxml.PhyloXmlMapping; import org.forester.io.parsers.phyloxml.XmlElement; -import org.forester.io.parsers.util.PhylogenyParserException; import org.forester.phylogeny.data.BranchColor; import org.forester.phylogeny.data.PhylogenyData; @@ -49,7 +49,7 @@ public class ColorParser implements PhylogenyDataPhyloXmlParser { } @Override - public PhylogenyData parse( final XmlElement element ) throws PhylogenyParserException { + public PhylogenyData parse( final XmlElement element ) throws PhyloXmlDataFormatException { int red = 0; int green = 0; int blue = 0; diff --git a/forester/java/src/org/forester/io/parsers/phyloxml/data/ConfidenceParser.java b/forester/java/src/org/forester/io/parsers/phyloxml/data/ConfidenceParser.java index bf34183..72bc11d 100644 --- a/forester/java/src/org/forester/io/parsers/phyloxml/data/ConfidenceParser.java +++ b/forester/java/src/org/forester/io/parsers/phyloxml/data/ConfidenceParser.java @@ -25,9 +25,9 @@ package org.forester.io.parsers.phyloxml.data; +import org.forester.io.parsers.phyloxml.PhyloXmlDataFormatException; import org.forester.io.parsers.phyloxml.PhyloXmlMapping; import org.forester.io.parsers.phyloxml.XmlElement; -import org.forester.io.parsers.util.PhylogenyParserException; import org.forester.phylogeny.data.Confidence; import org.forester.phylogeny.data.PhylogenyData; @@ -47,7 +47,7 @@ public class ConfidenceParser implements PhylogenyDataPhyloXmlParser { } @Override - public PhylogenyData parse( final XmlElement element ) throws PhylogenyParserException { + public PhylogenyData parse( final XmlElement element ) throws PhyloXmlDataFormatException { final Confidence confidence = new Confidence(); confidence.setValue( element.getValueAsDouble() ); if ( element.isHasAttribute( PhyloXmlMapping.CONFIDENCE_TYPE_ATTR ) ) { @@ -59,7 +59,7 @@ public class ConfidenceParser implements PhylogenyDataPhyloXmlParser { .getAttribute( PhyloXmlMapping.CONFIDENCE_SD_ATTR ) ) ); } catch ( final NumberFormatException ex ) { - throw new PhylogenyParserException( "attempt to parse [" + throw new PhyloXmlDataFormatException( "attempt to parse [" + element.getAttribute( PhyloXmlMapping.CONFIDENCE_SD_ATTR + "] into double" ) ); } } diff --git a/forester/java/src/org/forester/io/parsers/phyloxml/data/DateParser.java b/forester/java/src/org/forester/io/parsers/phyloxml/data/DateParser.java index 2e86f28..780b84d 100644 --- a/forester/java/src/org/forester/io/parsers/phyloxml/data/DateParser.java +++ b/forester/java/src/org/forester/io/parsers/phyloxml/data/DateParser.java @@ -27,9 +27,9 @@ package org.forester.io.parsers.phyloxml.data; import java.math.BigDecimal; +import org.forester.io.parsers.phyloxml.PhyloXmlDataFormatException; import org.forester.io.parsers.phyloxml.PhyloXmlMapping; import org.forester.io.parsers.phyloxml.XmlElement; -import org.forester.io.parsers.util.PhylogenyParserException; import org.forester.phylogeny.data.Date; import org.forester.phylogeny.data.PhylogenyData; import org.forester.util.ForesterUtil; @@ -50,7 +50,7 @@ public class DateParser implements PhylogenyDataPhyloXmlParser { } @Override - public PhylogenyData parse( final XmlElement element ) throws PhylogenyParserException { + public PhylogenyData parse( final XmlElement element ) throws PhyloXmlDataFormatException { String unit = ""; if ( element.isHasAttribute( PhyloXmlMapping.CLADE_DATE_UNIT ) ) { unit = element.getAttribute( PhyloXmlMapping.CLADE_DATE_UNIT ); diff --git a/forester/java/src/org/forester/io/parsers/phyloxml/data/DistributionParser.java b/forester/java/src/org/forester/io/parsers/phyloxml/data/DistributionParser.java index 93db97e..904204d 100644 --- a/forester/java/src/org/forester/io/parsers/phyloxml/data/DistributionParser.java +++ b/forester/java/src/org/forester/io/parsers/phyloxml/data/DistributionParser.java @@ -28,9 +28,9 @@ package org.forester.io.parsers.phyloxml.data; import java.util.ArrayList; import java.util.List; +import org.forester.io.parsers.phyloxml.PhyloXmlDataFormatException; import org.forester.io.parsers.phyloxml.PhyloXmlMapping; import org.forester.io.parsers.phyloxml.XmlElement; -import org.forester.io.parsers.util.PhylogenyParserException; import org.forester.phylogeny.data.Distribution; import org.forester.phylogeny.data.PhylogenyData; import org.forester.phylogeny.data.Point; @@ -52,7 +52,7 @@ public class DistributionParser implements PhylogenyDataPhyloXmlParser { } @Override - public PhylogenyData parse( final XmlElement element ) throws PhylogenyParserException { + public PhylogenyData parse( final XmlElement element ) throws PhyloXmlDataFormatException { String desc = ""; List points = null; List polygons = null; diff --git a/forester/java/src/org/forester/io/parsers/phyloxml/data/DomainArchitectureParser.java b/forester/java/src/org/forester/io/parsers/phyloxml/data/DomainArchitectureParser.java index 34bba14..e76ba6a 100644 --- a/forester/java/src/org/forester/io/parsers/phyloxml/data/DomainArchitectureParser.java +++ b/forester/java/src/org/forester/io/parsers/phyloxml/data/DomainArchitectureParser.java @@ -25,9 +25,9 @@ package org.forester.io.parsers.phyloxml.data; +import org.forester.io.parsers.phyloxml.PhyloXmlDataFormatException; import org.forester.io.parsers.phyloxml.PhyloXmlMapping; import org.forester.io.parsers.phyloxml.XmlElement; -import org.forester.io.parsers.util.PhylogenyParserException; import org.forester.phylogeny.data.DomainArchitecture; import org.forester.phylogeny.data.ProteinDomain; @@ -47,10 +47,10 @@ public class DomainArchitectureParser implements PhylogenyDataPhyloXmlParser { } @Override - public DomainArchitecture parse( final XmlElement element ) throws PhylogenyParserException { + public DomainArchitecture parse( final XmlElement element ) throws PhyloXmlDataFormatException { final DomainArchitecture architecure = new DomainArchitecture(); if ( !element.isHasAttribute( PhyloXmlMapping.SEQUENCE_DOMAIN_ARCHITECTURE_LENGTH ) ) { - throw new PhylogenyParserException( PhyloXmlMapping.SEQUENCE_DOMAIN_ARCHITECTURE_LENGTH + throw new PhyloXmlDataFormatException( PhyloXmlMapping.SEQUENCE_DOMAIN_ARCHITECTURE_LENGTH + " attribute is required for domain architecture" ); } final String lenght_str = element.getAttribute( PhyloXmlMapping.SEQUENCE_DOMAIN_ARCHITECTURE_LENGTH ); @@ -58,7 +58,7 @@ public class DomainArchitectureParser implements PhylogenyDataPhyloXmlParser { architecure.setTotalLength( Integer.parseInt( lenght_str ) ); } catch ( final NumberFormatException e ) { - throw new PhylogenyParserException( "could not extract domain architecture length from [" + lenght_str + throw new PhyloXmlDataFormatException( "could not extract domain architecture length from [" + lenght_str + "]: " + e.getMessage() ); } for( int i = 0; i < element.getNumberOfChildElements(); ++i ) { diff --git a/forester/java/src/org/forester/io/parsers/phyloxml/data/EventParser.java b/forester/java/src/org/forester/io/parsers/phyloxml/data/EventParser.java index 3c6a45f..5c2ee69 100644 --- a/forester/java/src/org/forester/io/parsers/phyloxml/data/EventParser.java +++ b/forester/java/src/org/forester/io/parsers/phyloxml/data/EventParser.java @@ -25,9 +25,9 @@ package org.forester.io.parsers.phyloxml.data; +import org.forester.io.parsers.phyloxml.PhyloXmlDataFormatException; import org.forester.io.parsers.phyloxml.PhyloXmlMapping; import org.forester.io.parsers.phyloxml.XmlElement; -import org.forester.io.parsers.util.PhylogenyParserException; import org.forester.phylogeny.data.Confidence; import org.forester.phylogeny.data.Event; import org.forester.phylogeny.data.PhylogenyData; @@ -49,7 +49,7 @@ public class EventParser implements PhylogenyDataPhyloXmlParser { } @Override - public PhylogenyData parse( final XmlElement element ) throws PhylogenyParserException { + public PhylogenyData parse( final XmlElement element ) throws PhyloXmlDataFormatException { String type = ""; Confidence conf = null; int duplications = Event.DEFAULT_VALUE; @@ -82,7 +82,7 @@ public class EventParser implements PhylogenyDataPhyloXmlParser { event = new Event( duplications, speciations, losses, type ); } catch ( final Exception e ) { - throw new PhylogenyParserException( "problem with " + element.toString() + ": " + e.getMessage() ); + throw new PhyloXmlDataFormatException( "problem with " + element.toString() + ": " + e.getMessage() ); } } if ( conf != null ) { diff --git a/forester/java/src/org/forester/io/parsers/phyloxml/data/IdentifierParser.java b/forester/java/src/org/forester/io/parsers/phyloxml/data/IdentifierParser.java index 2f64245..544188c 100644 --- a/forester/java/src/org/forester/io/parsers/phyloxml/data/IdentifierParser.java +++ b/forester/java/src/org/forester/io/parsers/phyloxml/data/IdentifierParser.java @@ -25,9 +25,9 @@ package org.forester.io.parsers.phyloxml.data; +import org.forester.io.parsers.phyloxml.PhyloXmlDataFormatException; import org.forester.io.parsers.phyloxml.PhyloXmlMapping; import org.forester.io.parsers.phyloxml.XmlElement; -import org.forester.io.parsers.util.PhylogenyParserException; import org.forester.phylogeny.data.Identifier; import org.forester.phylogeny.data.PhylogenyData; @@ -48,7 +48,7 @@ public class IdentifierParser implements PhylogenyDataPhyloXmlParser { } @Override - public PhylogenyData parse( final XmlElement element ) throws PhylogenyParserException { + public PhylogenyData parse( final XmlElement element ) throws PhyloXmlDataFormatException { if ( element.isHasAttribute( PhyloXmlMapping.IDENTIFIER_PROVIDER_ATTR ) ) { return new Identifier( element.getValueAsString(), element.getAttribute( PhyloXmlMapping.IDENTIFIER_PROVIDER_ATTR ) ); diff --git a/forester/java/src/org/forester/io/parsers/phyloxml/data/PhylogenyDataPhyloXmlParser.java b/forester/java/src/org/forester/io/parsers/phyloxml/data/PhylogenyDataPhyloXmlParser.java index d8db199..f74220e 100644 --- a/forester/java/src/org/forester/io/parsers/phyloxml/data/PhylogenyDataPhyloXmlParser.java +++ b/forester/java/src/org/forester/io/parsers/phyloxml/data/PhylogenyDataPhyloXmlParser.java @@ -26,11 +26,11 @@ package org.forester.io.parsers.phyloxml.data; +import org.forester.io.parsers.phyloxml.PhyloXmlDataFormatException; import org.forester.io.parsers.phyloxml.XmlElement; -import org.forester.io.parsers.util.PhylogenyParserException; import org.forester.phylogeny.data.PhylogenyData; public interface PhylogenyDataPhyloXmlParser { - public PhylogenyData parse( final XmlElement element ) throws PhylogenyParserException; + public PhylogenyData parse( final XmlElement element ) throws PhyloXmlDataFormatException; } \ No newline at end of file diff --git a/forester/java/src/org/forester/io/parsers/phyloxml/data/PointParser.java b/forester/java/src/org/forester/io/parsers/phyloxml/data/PointParser.java index a2bd3be..e795460 100644 --- a/forester/java/src/org/forester/io/parsers/phyloxml/data/PointParser.java +++ b/forester/java/src/org/forester/io/parsers/phyloxml/data/PointParser.java @@ -27,9 +27,9 @@ package org.forester.io.parsers.phyloxml.data; import java.math.BigDecimal; +import org.forester.io.parsers.phyloxml.PhyloXmlDataFormatException; import org.forester.io.parsers.phyloxml.PhyloXmlMapping; import org.forester.io.parsers.phyloxml.XmlElement; -import org.forester.io.parsers.util.PhylogenyParserException; import org.forester.phylogeny.data.PhylogenyData; import org.forester.phylogeny.data.Point; import org.forester.util.ForesterUtil; @@ -50,7 +50,7 @@ public class PointParser implements PhylogenyDataPhyloXmlParser { } @Override - public PhylogenyData parse( final XmlElement element ) throws PhylogenyParserException { + public PhylogenyData parse( final XmlElement element ) throws PhyloXmlDataFormatException { String alt_unit = ""; String geo_datum = ""; if ( element.isHasAttribute( PhyloXmlMapping.POINT_ALTITUDE_UNIT_ATTR ) ) { diff --git a/forester/java/src/org/forester/io/parsers/phyloxml/data/PolygonParser.java b/forester/java/src/org/forester/io/parsers/phyloxml/data/PolygonParser.java index 395e14d..447a641 100644 --- a/forester/java/src/org/forester/io/parsers/phyloxml/data/PolygonParser.java +++ b/forester/java/src/org/forester/io/parsers/phyloxml/data/PolygonParser.java @@ -28,9 +28,9 @@ package org.forester.io.parsers.phyloxml.data; import java.util.ArrayList; import java.util.List; +import org.forester.io.parsers.phyloxml.PhyloXmlDataFormatException; import org.forester.io.parsers.phyloxml.PhyloXmlMapping; import org.forester.io.parsers.phyloxml.XmlElement; -import org.forester.io.parsers.util.PhylogenyParserException; import org.forester.phylogeny.data.PhylogenyData; import org.forester.phylogeny.data.Point; import org.forester.phylogeny.data.Polygon; @@ -51,7 +51,7 @@ public class PolygonParser implements PhylogenyDataPhyloXmlParser { } @Override - public PhylogenyData parse( final XmlElement element ) throws PhylogenyParserException { + public PhylogenyData parse( final XmlElement element ) throws PhyloXmlDataFormatException { final List points = new ArrayList(); for( int j = 0; j < element.getNumberOfChildElements(); ++j ) { final XmlElement e = element.getChildElement( j ); diff --git a/forester/java/src/org/forester/io/parsers/phyloxml/data/PropertyParser.java b/forester/java/src/org/forester/io/parsers/phyloxml/data/PropertyParser.java index b4baa8f..42682b2 100644 --- a/forester/java/src/org/forester/io/parsers/phyloxml/data/PropertyParser.java +++ b/forester/java/src/org/forester/io/parsers/phyloxml/data/PropertyParser.java @@ -25,9 +25,9 @@ package org.forester.io.parsers.phyloxml.data; +import org.forester.io.parsers.phyloxml.PhyloXmlDataFormatException; import org.forester.io.parsers.phyloxml.PhyloXmlMapping; import org.forester.io.parsers.phyloxml.XmlElement; -import org.forester.io.parsers.util.PhylogenyParserException; import org.forester.phylogeny.data.PhylogenyData; import org.forester.phylogeny.data.Property; import org.forester.phylogeny.data.Property.AppliesTo; @@ -49,7 +49,7 @@ public class PropertyParser implements PhylogenyDataPhyloXmlParser { } @Override - public PhylogenyData parse( final XmlElement element ) throws PhylogenyParserException { + public PhylogenyData parse( final XmlElement element ) throws PhyloXmlDataFormatException { String ref = ""; String value = ""; String unit = ""; diff --git a/forester/java/src/org/forester/io/parsers/phyloxml/data/ProteinDomainParser.java b/forester/java/src/org/forester/io/parsers/phyloxml/data/ProteinDomainParser.java index e32096e..75498cd 100644 --- a/forester/java/src/org/forester/io/parsers/phyloxml/data/ProteinDomainParser.java +++ b/forester/java/src/org/forester/io/parsers/phyloxml/data/ProteinDomainParser.java @@ -25,9 +25,9 @@ package org.forester.io.parsers.phyloxml.data; +import org.forester.io.parsers.phyloxml.PhyloXmlDataFormatException; import org.forester.io.parsers.phyloxml.PhyloXmlMapping; import org.forester.io.parsers.phyloxml.XmlElement; -import org.forester.io.parsers.util.PhylogenyParserException; import org.forester.phylogeny.data.ProteinDomain; public class ProteinDomainParser implements PhylogenyDataPhyloXmlParser { @@ -46,7 +46,7 @@ public class ProteinDomainParser implements PhylogenyDataPhyloXmlParser { } @Override - public ProteinDomain parse( final XmlElement element ) throws PhylogenyParserException { + public ProteinDomain parse( final XmlElement element ) throws PhyloXmlDataFormatException { String name = ""; int f = -1; int t = -1; @@ -63,11 +63,11 @@ public class ProteinDomainParser implements PhylogenyDataPhyloXmlParser { } } catch ( final Exception e ) { - throw new PhylogenyParserException( "failed to parse element [" + element + "]: " + e.getMessage() ); + throw new PhyloXmlDataFormatException( "failed to parse element [" + element + "]: " + e.getMessage() ); } name = element.getValueAsString(); if ( ( f == -1 ) || ( t == -1 ) || ( conf == ProteinDomain.CONFIDENCE_DEFAULT ) ) { - throw new PhylogenyParserException( "from, to, or confidence attribute not set in: " + element ); + throw new PhyloXmlDataFormatException( "from, to, or confidence attribute not set in: " + element ); } return new ProteinDomain( name, f, t, id, conf ); } diff --git a/forester/java/src/org/forester/io/parsers/phyloxml/data/ReferenceParser.java b/forester/java/src/org/forester/io/parsers/phyloxml/data/ReferenceParser.java index 47f0f17..5a81ed7 100644 --- a/forester/java/src/org/forester/io/parsers/phyloxml/data/ReferenceParser.java +++ b/forester/java/src/org/forester/io/parsers/phyloxml/data/ReferenceParser.java @@ -25,9 +25,9 @@ package org.forester.io.parsers.phyloxml.data; +import org.forester.io.parsers.phyloxml.PhyloXmlDataFormatException; import org.forester.io.parsers.phyloxml.PhyloXmlMapping; import org.forester.io.parsers.phyloxml.XmlElement; -import org.forester.io.parsers.util.PhylogenyParserException; import org.forester.phylogeny.data.PhylogenyData; import org.forester.phylogeny.data.Reference; import org.forester.util.ForesterUtil; @@ -48,7 +48,7 @@ public class ReferenceParser implements PhylogenyDataPhyloXmlParser { } @Override - public PhylogenyData parse( final XmlElement element ) throws PhylogenyParserException { + public PhylogenyData parse( final XmlElement element ) throws PhyloXmlDataFormatException { String desc = ""; String doi = ""; if ( element.isHasAttribute( PhyloXmlMapping.REFERENCE_DOI_ATTR ) ) { diff --git a/forester/java/src/org/forester/io/parsers/phyloxml/data/SequenceParser.java b/forester/java/src/org/forester/io/parsers/phyloxml/data/SequenceParser.java index f0abd4b..5208b9f 100644 --- a/forester/java/src/org/forester/io/parsers/phyloxml/data/SequenceParser.java +++ b/forester/java/src/org/forester/io/parsers/phyloxml/data/SequenceParser.java @@ -25,9 +25,9 @@ package org.forester.io.parsers.phyloxml.data; +import org.forester.io.parsers.phyloxml.PhyloXmlDataFormatException; import org.forester.io.parsers.phyloxml.PhyloXmlMapping; import org.forester.io.parsers.phyloxml.XmlElement; -import org.forester.io.parsers.util.PhylogenyParserException; import org.forester.phylogeny.data.Accession; import org.forester.phylogeny.data.Annotation; import org.forester.phylogeny.data.DomainArchitecture; @@ -50,7 +50,7 @@ public class SequenceParser implements PhylogenyDataPhyloXmlParser { } @Override - public Sequence parse( final XmlElement element ) throws PhylogenyParserException { + public Sequence parse( final XmlElement element ) throws PhyloXmlDataFormatException { final Sequence sequence = new Sequence(); if ( element.isHasAttribute( PhyloXmlMapping.SEQUENCE_TYPE ) ) { sequence.setType( element.getAttribute( PhyloXmlMapping.SEQUENCE_TYPE ) ); diff --git a/forester/java/src/org/forester/io/parsers/phyloxml/data/SequenceRelationParser.java b/forester/java/src/org/forester/io/parsers/phyloxml/data/SequenceRelationParser.java index edd6d37..624944d 100644 --- a/forester/java/src/org/forester/io/parsers/phyloxml/data/SequenceRelationParser.java +++ b/forester/java/src/org/forester/io/parsers/phyloxml/data/SequenceRelationParser.java @@ -28,10 +28,10 @@ package org.forester.io.parsers.phyloxml.data; import java.util.HashMap; import java.util.Map; +import org.forester.io.parsers.phyloxml.PhyloXmlDataFormatException; import org.forester.io.parsers.phyloxml.PhyloXmlHandler; import org.forester.io.parsers.phyloxml.PhyloXmlMapping; import org.forester.io.parsers.phyloxml.XmlElement; -import org.forester.io.parsers.util.PhylogenyParserException; import org.forester.phylogeny.Phylogeny; import org.forester.phylogeny.data.Confidence; import org.forester.phylogeny.data.Sequence; @@ -46,7 +46,7 @@ public class SequenceRelationParser implements PhylogenyDataPhyloXmlParser { } @Override - public SequenceRelation parse( final XmlElement element ) throws PhylogenyParserException { + public SequenceRelation parse( final XmlElement element ) throws PhyloXmlDataFormatException { final SequenceRelation seqRelation = new SequenceRelation(); if ( element.isHasAttribute( PhyloXmlMapping.SEQUENCE_RELATION_TYPE ) ) { final String sType = element.getAttribute( PhyloXmlMapping.SEQUENCE_RELATION_TYPE ); diff --git a/forester/java/src/org/forester/io/parsers/phyloxml/data/TaxonomyParser.java b/forester/java/src/org/forester/io/parsers/phyloxml/data/TaxonomyParser.java index 879cd5a..a9ffca2 100644 --- a/forester/java/src/org/forester/io/parsers/phyloxml/data/TaxonomyParser.java +++ b/forester/java/src/org/forester/io/parsers/phyloxml/data/TaxonomyParser.java @@ -25,9 +25,9 @@ package org.forester.io.parsers.phyloxml.data; +import org.forester.io.parsers.phyloxml.PhyloXmlDataFormatException; import org.forester.io.parsers.phyloxml.PhyloXmlMapping; import org.forester.io.parsers.phyloxml.XmlElement; -import org.forester.io.parsers.util.PhylogenyParserException; import org.forester.phylogeny.data.Identifier; import org.forester.phylogeny.data.Taxonomy; import org.forester.phylogeny.data.Uri; @@ -48,7 +48,7 @@ public class TaxonomyParser implements PhylogenyDataPhyloXmlParser { } @Override - public Taxonomy parse( final XmlElement element ) throws PhylogenyParserException { + public Taxonomy parse( final XmlElement element ) throws PhyloXmlDataFormatException { final Taxonomy taxonomy = new Taxonomy(); for( int i = 0; i < element.getNumberOfChildElements(); ++i ) { final XmlElement child_element = element.getChildElement( i ); diff --git a/forester/java/src/org/forester/io/parsers/phyloxml/data/UriParser.java b/forester/java/src/org/forester/io/parsers/phyloxml/data/UriParser.java index 43404de..40f5fa3 100644 --- a/forester/java/src/org/forester/io/parsers/phyloxml/data/UriParser.java +++ b/forester/java/src/org/forester/io/parsers/phyloxml/data/UriParser.java @@ -28,9 +28,9 @@ package org.forester.io.parsers.phyloxml.data; import java.net.URI; import java.net.URISyntaxException; +import org.forester.io.parsers.phyloxml.PhyloXmlDataFormatException; import org.forester.io.parsers.phyloxml.PhyloXmlMapping; import org.forester.io.parsers.phyloxml.XmlElement; -import org.forester.io.parsers.util.PhylogenyParserException; import org.forester.phylogeny.data.PhylogenyData; import org.forester.phylogeny.data.Uri; @@ -50,7 +50,7 @@ public class UriParser implements PhylogenyDataPhyloXmlParser { } @Override - public PhylogenyData parse( final XmlElement element ) throws PhylogenyParserException { + public PhylogenyData parse( final XmlElement element ) throws PhyloXmlDataFormatException { String type = ""; String desc = ""; URI uri = null; @@ -58,7 +58,7 @@ public class UriParser implements PhylogenyDataPhyloXmlParser { uri = new URI( element.getValueAsString() ); } catch ( final URISyntaxException e ) { - throw new PhylogenyParserException( "ill formatted Uri: " + element.getValueAsString() ); + throw new PhyloXmlDataFormatException( "ill formatted Uri: " + element.getValueAsString() ); } if ( element.isHasAttribute( PhyloXmlMapping.URI_DESC_ATTR ) ) { desc = element.getAttribute( PhyloXmlMapping.URI_DESC_ATTR ); diff --git a/forester/java/src/org/forester/io/parsers/util/ParserUtils.java b/forester/java/src/org/forester/io/parsers/util/ParserUtils.java index f7b61f7..bb89472 100644 --- a/forester/java/src/org/forester/io/parsers/util/ParserUtils.java +++ b/forester/java/src/org/forester/io/parsers/util/ParserUtils.java @@ -124,7 +124,8 @@ public final class ParserUtils { else if ( filename_lc.endsWith( ".nexus" ) || filename_lc.endsWith( ".nex" ) || filename_lc.endsWith( ".nx" ) ) { parser = new NexusPhylogeniesParser(); } - else if ( filename_lc.endsWith( ".nhx" ) || filename_lc.endsWith( ".nh" ) || filename_lc.endsWith( ".newick" ) || filename_lc.endsWith( ".nwk" ) ) { + else if ( filename_lc.endsWith( ".nhx" ) || filename_lc.endsWith( ".nh" ) || filename_lc.endsWith( ".newick" ) + || filename_lc.endsWith( ".nwk" ) ) { parser = new NHXParser(); } return parser; diff --git a/forester/java/src/org/forester/io/writers/PhylogenyWriter.java b/forester/java/src/org/forester/io/writers/PhylogenyWriter.java index 8ee4522..512921e 100644 --- a/forester/java/src/org/forester/io/writers/PhylogenyWriter.java +++ b/forester/java/src/org/forester/io/writers/PhylogenyWriter.java @@ -481,10 +481,8 @@ public final class PhylogenyWriter { writer.flush(); writer.close(); } - - public void toPhyloXML( final Phylogeny phy, - final int phyloxml_level, - final File out_file ) throws IOException { + + public void toPhyloXML( final Phylogeny phy, final int phyloxml_level, final File out_file ) throws IOException { final Writer writer = new BufferedWriter( new PrintWriter( out_file ) ); toPhyloXML( writer, phy, phyloxml_level ); writer.flush(); diff --git a/forester/java/src/org/forester/phylogeny/Phylogeny.java b/forester/java/src/org/forester/phylogeny/Phylogeny.java index 42470ba..b1677b1 100644 --- a/forester/java/src/org/forester/phylogeny/Phylogeny.java +++ b/forester/java/src/org/forester/phylogeny/Phylogeny.java @@ -221,10 +221,10 @@ public class Phylogeny { * @param remove_us the parent node of the subtree to be deleted */ public void deleteSubtree( final PhylogenyNode remove_us, final boolean collapse_resulting_node_with_one_desc ) { - if ( isEmpty() || ( remove_us.isRoot() && getNumberOfExternalNodes() != 1 ) ) { + if ( isEmpty() || ( remove_us.isRoot() && ( getNumberOfExternalNodes() != 1 ) ) ) { return; } - if ( remove_us.isRoot() && getNumberOfExternalNodes() == 1 ) { + if ( remove_us.isRoot() && ( getNumberOfExternalNodes() == 1 ) ) { init(); } else if ( !collapse_resulting_node_with_one_desc ) { diff --git a/forester/java/src/org/forester/phylogeny/PhylogenyMethods.java b/forester/java/src/org/forester/phylogeny/PhylogenyMethods.java index bb13e65..a4658f0 100644 --- a/forester/java/src/org/forester/phylogeny/PhylogenyMethods.java +++ b/forester/java/src/org/forester/phylogeny/PhylogenyMethods.java @@ -40,6 +40,7 @@ import java.util.SortedMap; import java.util.TreeMap; import org.forester.io.parsers.PhylogenyParser; +import org.forester.io.parsers.phyloxml.PhyloXmlDataFormatException; import org.forester.io.parsers.phyloxml.PhyloXmlUtil; import org.forester.io.parsers.util.PhylogenyParserException; import org.forester.phylogeny.data.BranchColor; @@ -393,10 +394,14 @@ public class PhylogenyMethods { } final static public void transferNodeNameToField( final Phylogeny phy, - final PhylogenyMethods.PhylogenyNodeField field ) { + final PhylogenyMethods.PhylogenyNodeField field, + final boolean external_only ) throws PhyloXmlDataFormatException { final PhylogenyNodeIterator it = phy.iteratorPostorder(); while ( it.hasNext() ) { final PhylogenyNode n = it.next(); + if ( external_only && n.isInternal() ) { + continue; + } final String name = n.getName().trim(); if ( !ForesterUtil.isEmpty( name ) ) { switch ( field ) { @@ -1557,8 +1562,10 @@ public class PhylogenyMethods { * * @param node * @param taxonomy_code + * @throws PhyloXmlDataFormatException */ - public static void setTaxonomyCode( final PhylogenyNode node, final String taxonomy_code ) { + public static void setTaxonomyCode( final PhylogenyNode node, final String taxonomy_code ) + throws PhyloXmlDataFormatException { if ( !node.getNodeData().isHasTaxonomy() ) { node.getNodeData().setTaxonomy( new Taxonomy() ); } diff --git a/forester/java/src/org/forester/phylogeny/PhylogenyNode.java b/forester/java/src/org/forester/phylogeny/PhylogenyNode.java index d8dd298..58dd0a3 100644 --- a/forester/java/src/org/forester/phylogeny/PhylogenyNode.java +++ b/forester/java/src/org/forester/phylogeny/PhylogenyNode.java @@ -32,6 +32,7 @@ import java.util.List; import org.forester.io.parsers.nhx.NHXFormatException; import org.forester.io.parsers.nhx.NHXParser; +import org.forester.io.parsers.phyloxml.PhyloXmlDataFormatException; import org.forester.io.parsers.phyloxml.PhyloXmlUtil; import org.forester.phylogeny.data.BranchData; import org.forester.phylogeny.data.Confidence; @@ -42,6 +43,12 @@ import org.forester.phylogeny.iterators.PhylogenyNodeIterator; import org.forester.phylogeny.iterators.PreorderTreeIterator; import org.forester.util.ForesterUtil; +/** + * Warning. Implementation of method 'compareTo' only looks at + * node name. Thus, use of this class in SortedSets might lead + * to unexpected behavior. + * + */ public final class PhylogenyNode implements PhylogenyNodeI, Comparable { private static int _node_count = 0; @@ -1058,8 +1065,8 @@ public final class PhylogenyNode implements PhylogenyNodeI, Comparable() ); for( final Uri uri : getUris() ) { @@ -253,8 +263,18 @@ public class Sequence implements PhylogenyData, MultipleUris { setMolecularSequenceAligned( false ); setLocation( "" ); setAccession( null ); - setSymbol( "" ); - setType( "" ); + try { + setSymbol( "" ); + } + catch ( final PhyloXmlDataFormatException e ) { + e.printStackTrace(); + } + try { + setType( "" ); + } + catch ( final PhyloXmlDataFormatException e ) { + e.printStackTrace(); + } setDomainArchitecture( null ); setUris( null ); setSequenceRelations( null ); @@ -306,14 +326,14 @@ public class Sequence implements PhylogenyData, MultipleUris { _source_id = source_id; } - public void setSymbol( final String symbol ) { + public void setSymbol( final String symbol ) throws PhyloXmlDataFormatException { if ( !ForesterUtil.isEmpty( symbol ) && !PhyloXmlUtil.SEQUENCE_SYMBOL_PATTERN.matcher( symbol ).matches() ) { throw new PhyloXmlDataFormatException( "illegal sequence symbol: [" + symbol + "]" ); } _symbol = symbol; } - public void setType( final String type ) { + public void setType( final String type ) throws PhyloXmlDataFormatException { if ( !ForesterUtil.isEmpty( type ) && !PhyloXmlUtil.SEQUENCE_TYPES.contains( type ) ) { throw new PhyloXmlDataFormatException( "illegal sequence type: [" + type + "]" ); } diff --git a/forester/java/src/org/forester/phylogeny/data/Taxonomy.java b/forester/java/src/org/forester/phylogeny/data/Taxonomy.java index 6d8ade1..544522b 100644 --- a/forester/java/src/org/forester/phylogeny/data/Taxonomy.java +++ b/forester/java/src/org/forester/phylogeny/data/Taxonomy.java @@ -109,7 +109,12 @@ public class Taxonomy implements PhylogenyData, MultipleUris, Comparable() ); for( final Uri uri : getUris() ) { @@ -218,8 +228,18 @@ public class Taxonomy implements PhylogenyData, MultipleUris, Comparable>" + x ); } for( final PhylogenyNode s : species_tree_ext_nodes ) { @@ -376,7 +376,7 @@ public final class GSDI extends SDI { System.out.println(); } } - for( PhylogenyNode x : _mapped_species_tree_nodes ) { + for( final PhylogenyNode x : _mapped_species_tree_nodes ) { System.out.println( ">>" + x ); } } diff --git a/forester/java/src/org/forester/test/Test.java b/forester/java/src/org/forester/test/Test.java index 814bf7c..4a8b8d8 100644 --- a/forester/java/src/org/forester/test/Test.java +++ b/forester/java/src/org/forester/test/Test.java @@ -104,7 +104,6 @@ import org.forester.util.ForesterConstants; import org.forester.util.ForesterUtil; import org.forester.util.GeneralTable; import org.forester.util.SequenceIdParser; -import org.forester.ws.seqdb.DatabaseTools; import org.forester.ws.seqdb.SequenceDatabaseEntry; import org.forester.ws.seqdb.SequenceDbWsTools; import org.forester.ws.seqdb.UniProtTaxonomy; @@ -172,11 +171,8 @@ public final class Test { System.exit( -1 ); } final long start_time = new Date().getTime(); - - - System.out.print( "Sequence id parsing: " ); - if ( testSequenceIdParsing() ) { + if ( testSequenceIdParsing() ) { System.out.println( "OK." ); succeeded++; } @@ -7850,8 +7846,8 @@ public final class Test { private static boolean testUniprotTaxonomySearch() { try { - List results = SequenceDbWsTools - .getTaxonomiesFromCommonNameStrict( "starlet sea anemone", 10 ); + List results = SequenceDbWsTools.getTaxonomiesFromCommonNameStrict( "starlet sea anemone", + 10 ); if ( results.size() != 1 ) { return false; } @@ -8921,15 +8917,12 @@ public final class Test { } return true; } - + private static boolean testSequenceIdParsing() { try { Identifier id = SequenceIdParser.parse( "gb_ADF31344_segmented_worms_" ); - if ( id == null - || ForesterUtil.isEmpty( id.getValue() ) - || ForesterUtil.isEmpty( id.getProvider() ) - || !id.getValue().equals( "ADF31344" ) - || !id.getProvider().equals( "ncbi" ) ) { + if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getProvider() ) + || !id.getValue().equals( "ADF31344" ) || !id.getProvider().equals( "ncbi" ) ) { if ( id != null ) { System.out.println( "value =" + id.getValue() ); System.out.println( "provider=" + id.getProvider() ); @@ -8938,11 +8931,8 @@ public final class Test { } // id = SequenceIdParser.parse( "segmented worms|gb_ADF31344" ); - if ( id == null - || ForesterUtil.isEmpty( id.getValue() ) - || ForesterUtil.isEmpty( id.getProvider() ) - || !id.getValue().equals( "ADF31344" ) - || !id.getProvider().equals( "ncbi" ) ) { + if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getProvider() ) + || !id.getValue().equals( "ADF31344" ) || !id.getProvider().equals( "ncbi" ) ) { if ( id != null ) { System.out.println( "value =" + id.getValue() ); System.out.println( "provider=" + id.getProvider() ); @@ -8951,25 +8941,18 @@ public final class Test { } // id = SequenceIdParser.parse( "segmented worms gb_ADF31344 and more" ); - if ( id == null - || ForesterUtil.isEmpty( id.getValue() ) - || ForesterUtil.isEmpty( id.getProvider() ) - || !id.getValue().equals( "ADF31344" ) - || !id.getProvider().equals( "ncbi" ) ) { + if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getProvider() ) + || !id.getValue().equals( "ADF31344" ) || !id.getProvider().equals( "ncbi" ) ) { if ( id != null ) { System.out.println( "value =" + id.getValue() ); System.out.println( "provider=" + id.getProvider() ); } return false; } - // id = SequenceIdParser.parse( "gb_AAA96518_1" ); - if ( id == null - || ForesterUtil.isEmpty( id.getValue() ) - || ForesterUtil.isEmpty( id.getProvider() ) - || !id.getValue().equals( "AAA96518" ) - || !id.getProvider().equals( "ncbi" ) ) { + if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getProvider() ) + || !id.getValue().equals( "AAA96518" ) || !id.getProvider().equals( "ncbi" ) ) { if ( id != null ) { System.out.println( "value =" + id.getValue() ); System.out.println( "provider=" + id.getProvider() ); @@ -8978,11 +8961,8 @@ public final class Test { } // id = SequenceIdParser.parse( "gb_EHB07727_1_rodents_" ); - if ( id == null - || ForesterUtil.isEmpty( id.getValue() ) - || ForesterUtil.isEmpty( id.getProvider() ) - || !id.getValue().equals( "EHB07727" ) - || !id.getProvider().equals( "ncbi" ) ) { + if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getProvider() ) + || !id.getValue().equals( "EHB07727" ) || !id.getProvider().equals( "ncbi" ) ) { if ( id != null ) { System.out.println( "value =" + id.getValue() ); System.out.println( "provider=" + id.getProvider() ); @@ -8991,11 +8971,8 @@ public final class Test { } // id = SequenceIdParser.parse( "dbj_BAF37827_1_turtles_" ); - if ( id == null - || ForesterUtil.isEmpty( id.getValue() ) - || ForesterUtil.isEmpty( id.getProvider() ) - || !id.getValue().equals( "BAF37827" ) - || !id.getProvider().equals( "ncbi" ) ) { + if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getProvider() ) + || !id.getValue().equals( "BAF37827" ) || !id.getProvider().equals( "ncbi" ) ) { if ( id != null ) { System.out.println( "value =" + id.getValue() ); System.out.println( "provider=" + id.getProvider() ); @@ -9004,11 +8981,8 @@ public final class Test { } // id = SequenceIdParser.parse( "emb_CAA73223_1_primates_" ); - if ( id == null - || ForesterUtil.isEmpty( id.getValue() ) - || ForesterUtil.isEmpty( id.getProvider() ) - || !id.getValue().equals( "CAA73223" ) - || !id.getProvider().equals( "ncbi" ) ) { + if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getProvider() ) + || !id.getValue().equals( "CAA73223" ) || !id.getProvider().equals( "ncbi" ) ) { if ( id != null ) { System.out.println( "value =" + id.getValue() ); System.out.println( "provider=" + id.getProvider() ); @@ -9017,11 +8991,8 @@ public final class Test { } // id = SequenceIdParser.parse( "mites|ref_XP_002434188_1" ); - if ( id == null - || ForesterUtil.isEmpty( id.getValue() ) - || ForesterUtil.isEmpty( id.getProvider() ) - || !id.getValue().equals( "XP_002434188" ) - || !id.getProvider().equals( "refseq" ) ) { + if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getProvider() ) + || !id.getValue().equals( "XP_002434188" ) || !id.getProvider().equals( "refseq" ) ) { if ( id != null ) { System.out.println( "value =" + id.getValue() ); System.out.println( "provider=" + id.getProvider() ); @@ -9030,11 +9001,8 @@ public final class Test { } // id = SequenceIdParser.parse( "mites_ref_XP_002434188_1_bla_XP_12345" ); - if ( id == null - || ForesterUtil.isEmpty( id.getValue() ) - || ForesterUtil.isEmpty( id.getProvider() ) - || !id.getValue().equals( "XP_002434188" ) - || !id.getProvider().equals( "refseq" ) ) { + if ( ( id == null ) || ForesterUtil.isEmpty( id.getValue() ) || ForesterUtil.isEmpty( id.getProvider() ) + || !id.getValue().equals( "XP_002434188" ) || !id.getProvider().equals( "refseq" ) ) { if ( id != null ) { System.out.println( "value =" + id.getValue() ); System.out.println( "provider=" + id.getProvider() ); @@ -9046,7 +9014,6 @@ public final class Test { if ( id != null ) { return false; } - // lcl_91970_unknown_ } catch ( final Exception e ) { diff --git a/forester/java/src/org/forester/tools/PhylogenyDecorator.java b/forester/java/src/org/forester/tools/PhylogenyDecorator.java index 6f62d8b..e67ae8e 100644 --- a/forester/java/src/org/forester/tools/PhylogenyDecorator.java +++ b/forester/java/src/org/forester/tools/PhylogenyDecorator.java @@ -34,6 +34,7 @@ import java.util.regex.Pattern; import org.forester.archaeopteryx.AptxUtil; import org.forester.io.parsers.nhx.NHXFormatException; +import org.forester.io.parsers.phyloxml.PhyloXmlDataFormatException; import org.forester.phylogeny.Phylogeny; import org.forester.phylogeny.PhylogenyNode; import org.forester.phylogeny.data.Accession; @@ -76,7 +77,7 @@ public final class PhylogenyDecorator { final Map> map, final boolean picky, final int numbers_of_chars_allowed_to_remove_if_not_found_in_map ) - throws IllegalArgumentException { + throws IllegalArgumentException, PhyloXmlDataFormatException { for( final PhylogenyNodeIterator iter = phylogeny.iteratorPostorder(); iter.hasNext(); ) { final PhylogenyNode node = iter.next(); final String name = node.getName(); @@ -175,6 +176,7 @@ public final class PhylogenyDecorator { * @param picky * @throws IllegalArgumentException * @throws NHXFormatException + * @throws PhyloXmlDataFormatException */ public static void decorate( final Phylogeny phylogeny, final Map map, @@ -186,7 +188,7 @@ public final class PhylogenyDecorator { final boolean process_similar_to, final int numbers_of_chars_allowed_to_remove_if_not_found_in_map, final boolean move_domain_numbers_at_end_to_middle ) throws IllegalArgumentException, - NHXFormatException { + NHXFormatException, PhyloXmlDataFormatException { PhylogenyDecorator.decorate( phylogeny, map, field, @@ -213,6 +215,7 @@ public final class PhylogenyDecorator { * @param intermediate_map * maps name (in phylogeny) to a intermediate value * @throws IllegalArgumentException + * @throws PhyloXmlDataFormatException */ public static void decorate( final Phylogeny phylogeny, final Map map, @@ -224,7 +227,8 @@ public final class PhylogenyDecorator { final boolean process_name_intelligently, final boolean process_similar_to, final int numbers_of_chars_allowed_to_remove_if_not_found_in_map, - final boolean move_domain_numbers_at_end_to_middle ) throws IllegalArgumentException { + final boolean move_domain_numbers_at_end_to_middle ) throws IllegalArgumentException, + PhyloXmlDataFormatException { if ( extract_bracketed_scientific_name && ( field == FIELD.TAXONOMY_SCIENTIFIC_NAME ) ) { throw new IllegalArgumentException( "Attempt to extract bracketed scientific name together with data field pointing to scientific name" ); } @@ -343,7 +347,7 @@ public final class PhylogenyDecorator { final Map> map, final boolean picky, final int numbers_of_chars_allowed_to_remove_if_not_found_in_map ) - throws IllegalArgumentException, NHXFormatException { + throws IllegalArgumentException, NHXFormatException, PhyloXmlDataFormatException { for( int i = 0; i < phylogenies.length; ++i ) { PhylogenyDecorator.decorate( phylogenies[ i ], map, @@ -362,7 +366,7 @@ public final class PhylogenyDecorator { final boolean process_similar_to, final int numbers_of_chars_allowed_to_remove_if_not_found_in_map, final boolean move_domain_numbers_at_end_to_middle ) throws IllegalArgumentException, - NHXFormatException { + NHXFormatException, PhyloXmlDataFormatException { for( int i = 0; i < phylogenies.length; ++i ) { PhylogenyDecorator.decorate( phylogenies[ i ], map, @@ -388,7 +392,7 @@ public final class PhylogenyDecorator { final boolean process_similar_to, final int numbers_of_chars_allowed_to_remove_if_not_found_in_map, final boolean move_domain_numbers_at_end_to_middle ) throws IllegalArgumentException, - NHXFormatException { + NHXFormatException, PhyloXmlDataFormatException { for( int i = 0; i < phylogenies.length; ++i ) { PhylogenyDecorator.decorate( phylogenies[ i ], map, diff --git a/forester/java/src/org/forester/util/EasyWriter.java b/forester/java/src/org/forester/util/EasyWriter.java index 5fc907d..f289555 100644 --- a/forester/java/src/org/forester/util/EasyWriter.java +++ b/forester/java/src/org/forester/util/EasyWriter.java @@ -8,7 +8,7 @@ public final class EasyWriter extends BufferedWriter { private final static String LINE_SEPARATOR = ForesterUtil.LINE_SEPARATOR; - public EasyWriter( BufferedWriter out ) { + public EasyWriter( final BufferedWriter out ) { super( out ); } diff --git a/forester/java/src/org/forester/util/ForesterConstants.java b/forester/java/src/org/forester/util/ForesterConstants.java index 39dd287..cb21569 100644 --- a/forester/java/src/org/forester/util/ForesterConstants.java +++ b/forester/java/src/org/forester/util/ForesterConstants.java @@ -29,7 +29,6 @@ public final class ForesterConstants { public final static String FORESTER_VERSION = "1.004"; public final static String FORESTER_DATE = "120619"; - public final static String PHYLO_XML_VERSION = "1.10"; public final static String PHYLO_XML_LOCATION = "http://www.phyloxml.org"; public final static String PHYLO_XML_XSD = "phyloxml.xsd"; @@ -39,7 +38,6 @@ public final class ForesterConstants { public final static String UTF8 = "UTF-8"; public final static String PHYLO_XML_REFERENCE = "Han MV and Zmasek CM (2009): \"phyloXML: XML for evolutionary biology and comparative genomics\", BMC Bioinformatics 10:356"; public final static boolean RELEASE = false; - public enum PhylogeneticTreeFormats { NH, NHX, NEXUS, PHYLOXML diff --git a/forester/java/src/org/forester/util/SequenceIdParser.java b/forester/java/src/org/forester/util/SequenceIdParser.java index d75a6dd..0856f34 100644 --- a/forester/java/src/org/forester/util/SequenceIdParser.java +++ b/forester/java/src/org/forester/util/SequenceIdParser.java @@ -35,8 +35,6 @@ import org.forester.phylogeny.data.Identifier; public final class SequenceIdParser { - - // gb_ADF31344_1_segmented_worms_ // gb_AAA96518_1 // gb_EHB07727_1_rodents_ @@ -46,7 +44,6 @@ public final class SequenceIdParser { // mites|ref_XP_002434188_1 // ref_XP_002434188_1_mites___ticks_ // ref_NP_001121530_1_frogs___toads_ - //The format for GenBank Accession numbers are: //Nucleotide: 1 letter + 5 numerals OR 2 letters + 6 numerals //Protein: 3 letters + 5 numerals @@ -57,15 +54,12 @@ public final class SequenceIdParser { .compile( "(?:\\A|.*[^a-zA-Z0-9])([A-Z]{2}\\d{6})(?:[^a-zA-Z0-9]|\\Z)" ); private final static Pattern GENBANK_PROTEIN_AC_PATTERN = Pattern .compile( "(?:\\A|.*[^a-zA-Z0-9])([A-Z]{3}\\d{5})(?:[^a-zA-Z0-9]|\\Z)" ); - // RefSeq accession numbers can be distinguished from GenBank accessions // by their distinct prefix format of 2 characters followed by an // underscore character ('_'). For example, a RefSeq protein accession is NP_015325. - private final static Pattern REFSEQ_PATTERN = Pattern - .compile( "(?:\\A|.*[^a-zA-Z0-9])([A-Z]{2}_\\d{6,})(?:[^a-zA-Z0-9]|\\Z)" ); + private final static Pattern REFSEQ_PATTERN = Pattern + .compile( "(?:\\A|.*[^a-zA-Z0-9])([A-Z]{2}_\\d{6,})(?:[^a-zA-Z0-9]|\\Z)" ); - - /** * Returns null if no match. * @@ -73,7 +67,6 @@ public final class SequenceIdParser { public final static Identifier parse( final String s ) { String v = parseGenbankAccessor( s ); if ( !ForesterUtil.isEmpty( v ) ) { - return new Identifier( v, Identifier.NCBI ); } v = parseRefSeqAccessor( s ); @@ -82,7 +75,7 @@ public final class SequenceIdParser { } return null; } - + /** * Returns null if no match. * @@ -108,25 +101,20 @@ public final class SequenceIdParser { } } } - + /** * Returns null if no match. * */ private final static String parseRefSeqAccessor( final String query ) { - Matcher m = REFSEQ_PATTERN.matcher( query ); + final Matcher m = REFSEQ_PATTERN.matcher( query ); if ( m.lookingAt() ) { return m.group( 1 ); } return null; } - - - + private SequenceIdParser() { // Hiding the constructor. } - - - } diff --git a/forester/java/src/org/forester/ws/seqdb/DatabaseTools.java b/forester/java/src/org/forester/ws/seqdb/DatabaseTools.java index b8ce477..c8e1a4b 100644 --- a/forester/java/src/org/forester/ws/seqdb/DatabaseTools.java +++ b/forester/java/src/org/forester/ws/seqdb/DatabaseTools.java @@ -1,10 +1,8 @@ package org.forester.ws.seqdb; - public class DatabaseTools { - static String extract( final String target, final String a, final String b ) { final int i_a = target.indexOf( a ); final int i_b = target.indexOf( b ); diff --git a/forester/java/src/org/forester/ws/seqdb/EbiDbEntry.java b/forester/java/src/org/forester/ws/seqdb/EbiDbEntry.java index 2f1a64e..d845951 100644 --- a/forester/java/src/org/forester/ws/seqdb/EbiDbEntry.java +++ b/forester/java/src/org/forester/ws/seqdb/EbiDbEntry.java @@ -47,11 +47,10 @@ public final class EbiDbEntry implements SequenceDatabaseEntry { throw new CloneNotSupportedException(); } - public static SequenceDatabaseEntry createInstanceFromPlainTextForRefSeq( final List lines ) { final EbiDbEntry e = new EbiDbEntry(); for( final String line : lines ) { - // System.out.println( "-" + line ); + // System.out.println( "-" + line ); if ( line.startsWith( "ACCESSION" ) ) { e.setPA( DatabaseTools.extract( line, "ACCESSION" ) ); } @@ -62,10 +61,7 @@ public final class EbiDbEntry implements SequenceDatabaseEntry { else { e.setDe( DatabaseTools.extract( line, "DEFINITION" ) ); } - - } - else if ( line.startsWith( "SOURCE" ) ) { if ( line.indexOf( "(" ) > 0 ) { e.setOs( DatabaseTools.extract( line, "SOURCE", "(" ) ); @@ -74,17 +70,13 @@ public final class EbiDbEntry implements SequenceDatabaseEntry { e.setOs( DatabaseTools.extract( line, "SOURCE" ) ); } } - } return e; } - - - + public static SequenceDatabaseEntry createInstanceFromPlainText( final List lines ) { final EbiDbEntry e = new EbiDbEntry(); for( final String line : lines ) { - if ( line.startsWith( "PA" ) ) { e.setPA( DatabaseTools.extract( line, "PA" ) ); } @@ -181,8 +173,8 @@ public final class EbiDbEntry implements SequenceDatabaseEntry { public String getProvider() { return _provider; } - + public void setProvider( final String provider ) { - _provider = provider; + _provider = provider; } } diff --git a/forester/java/src/org/forester/ws/seqdb/SequenceDatabaseEntry.java b/forester/java/src/org/forester/ws/seqdb/SequenceDatabaseEntry.java index 8025dfc..9ae7892 100644 --- a/forester/java/src/org/forester/ws/seqdb/SequenceDatabaseEntry.java +++ b/forester/java/src/org/forester/ws/seqdb/SequenceDatabaseEntry.java @@ -30,7 +30,7 @@ public interface SequenceDatabaseEntry { public boolean isEmpty(); public String getAccession(); - + public String getProvider(); public String getSequenceName(); diff --git a/forester/java/src/org/forester/ws/seqdb/SequenceDbWsTools.java b/forester/java/src/org/forester/ws/seqdb/SequenceDbWsTools.java index f8d23e3..8c62173 100644 --- a/forester/java/src/org/forester/ws/seqdb/SequenceDbWsTools.java +++ b/forester/java/src/org/forester/ws/seqdb/SequenceDbWsTools.java @@ -47,12 +47,11 @@ public final class SequenceDbWsTools { public enum Db { UNKNOWN, UNIPROT; } - public final static String BASE_UNIPROT_URL = "http://www.uniprot.org/"; - public final static String BASE_EMBL_DB_URL = "http://www.ebi.ac.uk/Tools/dbfetch/dbfetch/"; - public final static String EMBL_DBS_EMBL = "embl"; - public final static String EMBL_DBS_REFSEQ_P = "refseqp"; - public final static String EMBL_DBS_REFSEQ_N = "refseqn"; - + public final static String BASE_UNIPROT_URL = "http://www.uniprot.org/"; + public final static String BASE_EMBL_DB_URL = "http://www.ebi.ac.uk/Tools/dbfetch/dbfetch/"; + public final static String EMBL_DBS_EMBL = "embl"; + public final static String EMBL_DBS_REFSEQ_P = "refseqp"; + public final static String EMBL_DBS_REFSEQ_N = "refseqn"; private final static String URL_ENC = "UTF-8"; // uniprot/expasy accession number format (6 chars): // letter digit letter-or-digit letter-or-digit letter-or-digit digit @@ -328,25 +327,20 @@ public final class SequenceDbWsTools { } public static List queryEmblDb( final Identifier id, final int max_lines_to_return ) throws IOException { - - StringBuilder url_sb = new StringBuilder(); + final StringBuilder url_sb = new StringBuilder(); url_sb.append( BASE_EMBL_DB_URL ); - - if ( ForesterUtil.isEmpty( id.getProvider() ) || id.getProvider().equalsIgnoreCase( Identifier.NCBI ) ) { - + if ( ForesterUtil.isEmpty( id.getProvider() ) || id.getProvider().equalsIgnoreCase( Identifier.NCBI ) ) { url_sb.append( SequenceDbWsTools.EMBL_DBS_EMBL ); - url_sb.append( '/'); + url_sb.append( '/' ); } else if ( id.getProvider().equalsIgnoreCase( Identifier.REFSEQ ) ) { if ( id.getValue().toUpperCase().indexOf( 'P' ) == 1 ) { - url_sb.append( SequenceDbWsTools.EMBL_DBS_REFSEQ_P ); - url_sb.append( '/'); + url_sb.append( '/' ); } else { - url_sb.append( SequenceDbWsTools.EMBL_DBS_REFSEQ_N ); - url_sb.append( '/'); + url_sb.append( '/' ); } } return queryDb( id.getValue(), max_lines_to_return, url_sb.toString() ); @@ -399,7 +393,7 @@ public final class SequenceDbWsTools { public static SequenceDatabaseEntry obtainEmblEntry( final Identifier id, final int max_lines_to_return ) throws IOException { - final List lines = queryEmblDb( id , max_lines_to_return ); + final List lines = queryEmblDb( id, max_lines_to_return ); return EbiDbEntry.createInstanceFromPlainText( lines ); } } diff --git a/forester/java/src/org/forester/ws/uniprot/DatabaseTools.java b/forester/java/src/org/forester/ws/uniprot/DatabaseTools.java index d30830c..77421fc 100644 --- a/forester/java/src/org/forester/ws/uniprot/DatabaseTools.java +++ b/forester/java/src/org/forester/ws/uniprot/DatabaseTools.java @@ -1,10 +1,8 @@ package org.forester.ws.uniprot; - public class DatabaseTools { - static String extract( final String target, final String a, final String b ) { final int i_a = target.indexOf( a ); final int i_b = target.indexOf( b ); diff --git a/forester/java/src/org/forester/ws/uniprot/EbiDbEntry.java b/forester/java/src/org/forester/ws/uniprot/EbiDbEntry.java index c840dff..59f1246 100644 --- a/forester/java/src/org/forester/ws/uniprot/EbiDbEntry.java +++ b/forester/java/src/org/forester/ws/uniprot/EbiDbEntry.java @@ -47,11 +47,10 @@ public final class EbiDbEntry implements SequenceDatabaseEntry { throw new CloneNotSupportedException(); } - public static SequenceDatabaseEntry createInstanceFromPlainTextForRefSeq( final List lines ) { final EbiDbEntry e = new EbiDbEntry(); for( final String line : lines ) { - // System.out.println( "-" + line ); + // System.out.println( "-" + line ); if ( line.startsWith( "ACCESSION" ) ) { e.setPA( DatabaseTools.extract( line, "ACCESSION" ) ); } @@ -62,10 +61,7 @@ public final class EbiDbEntry implements SequenceDatabaseEntry { else { e.setDe( DatabaseTools.extract( line, "DEFINITION" ) ); } - - } - else if ( line.startsWith( "SOURCE" ) ) { if ( line.indexOf( "(" ) > 0 ) { e.setOs( DatabaseTools.extract( line, "SOURCE", "(" ) ); @@ -74,17 +70,13 @@ public final class EbiDbEntry implements SequenceDatabaseEntry { e.setOs( DatabaseTools.extract( line, "SOURCE" ) ); } } - } return e; } - - - + public static SequenceDatabaseEntry createInstanceFromPlainText( final List lines ) { final EbiDbEntry e = new EbiDbEntry(); for( final String line : lines ) { - if ( line.startsWith( "PA" ) ) { e.setPA( DatabaseTools.extract( line, "PA" ) ); } @@ -181,8 +173,8 @@ public final class EbiDbEntry implements SequenceDatabaseEntry { public String getProvider() { return _provider; } - + public void setProvider( final String provider ) { - _provider = provider; + _provider = provider; } } diff --git a/forester/java/src/org/forester/ws/uniprot/SequenceDatabaseEntry.java b/forester/java/src/org/forester/ws/uniprot/SequenceDatabaseEntry.java index a98c004..fe3d975 100644 --- a/forester/java/src/org/forester/ws/uniprot/SequenceDatabaseEntry.java +++ b/forester/java/src/org/forester/ws/uniprot/SequenceDatabaseEntry.java @@ -30,7 +30,7 @@ public interface SequenceDatabaseEntry { public boolean isEmpty(); public String getAccession(); - + public String getProvider(); public String getSequenceName(); diff --git a/forester/java/src/org/forester/ws/uniprot/SequenceDbWsTools.java b/forester/java/src/org/forester/ws/uniprot/SequenceDbWsTools.java index 83f3c6f..64faed9 100644 --- a/forester/java/src/org/forester/ws/uniprot/SequenceDbWsTools.java +++ b/forester/java/src/org/forester/ws/uniprot/SequenceDbWsTools.java @@ -47,12 +47,11 @@ public final class SequenceDbWsTools { public enum Db { UNKNOWN, UNIPROT; } - public final static String BASE_UNIPROT_URL = "http://www.uniprot.org/"; - public final static String BASE_EMBL_DB_URL = "http://www.ebi.ac.uk/Tools/dbfetch/dbfetch/"; - public final static String EMBL_DBS_EMBL = "embl"; - public final static String EMBL_DBS_REFSEQ_P = "refseqp"; - public final static String EMBL_DBS_REFSEQ_N = "refseqn"; - + public final static String BASE_UNIPROT_URL = "http://www.uniprot.org/"; + public final static String BASE_EMBL_DB_URL = "http://www.ebi.ac.uk/Tools/dbfetch/dbfetch/"; + public final static String EMBL_DBS_EMBL = "embl"; + public final static String EMBL_DBS_REFSEQ_P = "refseqp"; + public final static String EMBL_DBS_REFSEQ_N = "refseqn"; private final static String URL_ENC = "UTF-8"; // uniprot/expasy accession number format (6 chars): // letter digit letter-or-digit letter-or-digit letter-or-digit digit @@ -328,25 +327,20 @@ public final class SequenceDbWsTools { } public static List queryEmblDb( final Identifier id, final int max_lines_to_return ) throws IOException { - - StringBuilder url_sb = new StringBuilder(); + final StringBuilder url_sb = new StringBuilder(); url_sb.append( BASE_EMBL_DB_URL ); - - if ( ForesterUtil.isEmpty( id.getProvider() ) || id.getProvider().equalsIgnoreCase( Identifier.NCBI ) ) { - + if ( ForesterUtil.isEmpty( id.getProvider() ) || id.getProvider().equalsIgnoreCase( Identifier.NCBI ) ) { url_sb.append( SequenceDbWsTools.EMBL_DBS_EMBL ); - url_sb.append( '/'); + url_sb.append( '/' ); } else if ( id.getProvider().equalsIgnoreCase( Identifier.REFSEQ ) ) { if ( id.getValue().toUpperCase().indexOf( 'P' ) == 1 ) { - url_sb.append( SequenceDbWsTools.EMBL_DBS_REFSEQ_P ); - url_sb.append( '/'); + url_sb.append( '/' ); } else { - url_sb.append( SequenceDbWsTools.EMBL_DBS_REFSEQ_N ); - url_sb.append( '/'); + url_sb.append( '/' ); } } return queryDb( id.getValue(), max_lines_to_return, url_sb.toString() ); @@ -399,7 +393,7 @@ public final class SequenceDbWsTools { public static SequenceDatabaseEntry obtainEmblEntry( final Identifier id, final int max_lines_to_return ) throws IOException { - final List lines = queryEmblDb( id , max_lines_to_return ); + final List lines = queryEmblDb( id, max_lines_to_return ); return EbiDbEntry.createInstanceFromPlainText( lines ); } }