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 );
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() );
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 );
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" );
ForesterUtil.fatalError( PRG_NAME, "phylogeny has " + phy.getNumberOfExternalNodes()
+ " external node(s), aborting" );
}
- final SortedSet<String> not_found = SequenceDataRetriver.obtainSeqInformation( phy, true , false);
+ final SortedSet<String> not_found = SequenceDataRetriver.obtainSeqInformation( phy, true, false );
for( final String remove_me : not_found ) {
phy.deleteSubtree( phy.getNode( remove_me ), true );
}
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" );
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 );
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() );
}
}
}
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 + " <options> <msa input file>" );
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;
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 {
}
if ( field != null ) {
for( final Phylogeny phy : phys ) {
- PhylogenyMethods.transferNodeNameToField( phy, field );
+ PhylogenyMethods.transferNodeNameToField( phy, field, false );
}
}
if ( midpoint_reroot ) {
+ ": 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();
}
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;
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;
dispose();
}
- private void extractTaxCodeFromNodeNames() {
+ private void extractTaxCodeFromNodeNames() throws PhyloXmlDataFormatException {
if ( getCurrentTreePanel() != null ) {
final Phylogeny phy = getCurrentTreePanel().getPhylogeny();
if ( ( phy != null ) && !phy.isEmpty() ) {
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 );
}
}
}
}
}
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 {
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;
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() );
_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();
}
}
}
- public static SortedSet<String> obtainSeqInformation( final Phylogeny phy, final boolean ext_nodes_only,
+ public static SortedSet<String> obtainSeqInformation( final Phylogeny phy,
+ final boolean ext_nodes_only,
final boolean allow_to_set_taxonomic_data )
throws IOException {
final SortedSet<String> not_found = new TreeSet<String>();
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;
}
}
- 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 );
}
}
}
- 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();
}
}
- 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();
}
}
- 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();
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;
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();
}
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();
}
}
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;
*
* @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(),
}
}
- 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() );
*
* @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();
*
* @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() );
*
* @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 ) {
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" );
}
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;
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 {
}
}
}
- catch ( final PhylogenyParserException ex ) {
+ catch ( final PhyloXmlDataFormatException ex ) {
throw new SAXException( ex.getMessage() );
}
}
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();
}
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 {
}
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();
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;
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;
}
@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 ) );
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;
}
@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 );
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;
}
@Override
- public PhylogenyData parse( final XmlElement element ) throws PhylogenyParserException {
+ public PhylogenyData parse( final XmlElement element ) throws PhyloXmlDataFormatException {
final SortedSet<String> present = new TreeSet<String>();
final SortedSet<String> gained = new TreeSet<String>();
final SortedSet<String> lost = new TreeSet<String>();
}
}
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 );
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;
}
@Override
- public PhylogenyData parse( final XmlElement element ) throws PhylogenyParserException {
+ public PhylogenyData parse( final XmlElement element ) throws PhyloXmlDataFormatException {
return new BranchWidth( element.getValueAsDouble() );
}
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;
}
@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;
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;
}
@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 ) ) {
.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" ) );
}
}
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;
}
@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 );
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;
}
@Override
- public PhylogenyData parse( final XmlElement element ) throws PhylogenyParserException {
+ public PhylogenyData parse( final XmlElement element ) throws PhyloXmlDataFormatException {
String desc = "";
List<Point> points = null;
List<Polygon> polygons = null;
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;
}
@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 );
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 ) {
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;
}
@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;
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 ) {
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;
}
@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 ) );
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
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;
}
@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 ) ) {
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;
}
@Override
- public PhylogenyData parse( final XmlElement element ) throws PhylogenyParserException {
+ public PhylogenyData parse( final XmlElement element ) throws PhyloXmlDataFormatException {
final List<Point> points = new ArrayList<Point>();
for( int j = 0; j < element.getNumberOfChildElements(); ++j ) {
final XmlElement e = element.getChildElement( j );
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;
}
@Override
- public PhylogenyData parse( final XmlElement element ) throws PhylogenyParserException {
+ public PhylogenyData parse( final XmlElement element ) throws PhyloXmlDataFormatException {
String ref = "";
String value = "";
String unit = "";
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 {
}
@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;
}
}
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 );
}
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;
}
@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 ) ) {
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;
}
@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 ) );
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;
}
@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 );
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;
}
@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 );
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;
}
@Override
- public PhylogenyData parse( final XmlElement element ) throws PhylogenyParserException {
+ public PhylogenyData parse( final XmlElement element ) throws PhyloXmlDataFormatException {
String type = "";
String desc = "";
URI uri = null;
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 );
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;
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();
* @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 ) {
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;
}
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 ) {
*
* @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() );
}
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;
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<PhylogenyNode> {
private static int _node_count = 0;
@Override
final public String toString() {
- StringBuilder sb = new StringBuilder();
- if ( ForesterUtil.isEmpty( getName() ) ) {
+ final StringBuilder sb = new StringBuilder();
+ if ( !ForesterUtil.isEmpty( getName() ) ) {
sb.append( getName() );
sb.append( " " );
}
PhylogenyNode._node_count = i;
}
- public static PhylogenyNode createInstanceFromNhxString( final String nhx ) throws NHXFormatException {
+ public static PhylogenyNode createInstanceFromNhxString( final String nhx ) throws NHXFormatException,
+ PhyloXmlDataFormatException {
return new PhylogenyNode( nhx, PhylogenyMethods.TAXONOMY_EXTRACTION.NO, false );
}
public static PhylogenyNode createInstanceFromNhxString( final String nhx,
final PhylogenyMethods.TAXONOMY_EXTRACTION taxonomy_extraction )
- throws NHXFormatException {
+ throws NHXFormatException, PhyloXmlDataFormatException {
return new PhylogenyNode( nhx, taxonomy_extraction, false );
}
public static PhylogenyNode createInstanceFromNhxString( final String nhx,
final PhylogenyMethods.TAXONOMY_EXTRACTION taxonomy_extraction,
final boolean replace_underscores )
- throws NHXFormatException {
+ throws NHXFormatException, PhyloXmlDataFormatException {
return new PhylogenyNode( nhx, taxonomy_extraction, replace_underscores );
}
private PhylogenyNode( final String nhx,
final PhylogenyMethods.TAXONOMY_EXTRACTION taxonomy_extraction,
- final boolean replace_underscores ) throws NHXFormatException {
+ final boolean replace_underscores ) throws NHXFormatException, PhyloXmlDataFormatException {
// init();
NHXParser.parseNHX( nhx, this, taxonomy_extraction, replace_underscores );
setId( PhylogenyNode.getNodeCount() );
@Override
public PhylogenyData copy() {
- return new Accession( getValue() , getSource() );
+ return new Accession( getValue(), getSource() );
}
@Override
&& ( ( Reference ) data ).getDoi().equals( getDoi() );
}
- public void setDoi( final String doi ) {
+ public void setDoi( final String doi ) throws PhyloXmlDataFormatException {
if ( !ForesterUtil.isEmpty( doi ) && !PhyloXmlUtil.LIT_REF_DOI_PATTERN.matcher( doi ).matches() ) {
throw new PhyloXmlDataFormatException( "illegal doi: [" + doi + "]" );
}
final Sequence seq = new Sequence();
seq.setAnnotations( getAnnotations() );
seq.setName( getName() );
- seq.setSymbol( getSymbol() );
+ try {
+ seq.setSymbol( getSymbol() );
+ }
+ catch ( final PhyloXmlDataFormatException e ) {
+ e.printStackTrace();
+ }
seq.setMolecularSequence( getMolecularSequence() );
seq.setMolecularSequenceAligned( isMolecularSequenceAligned() );
seq.setLocation( getLocation() );
else {
seq.setAccession( null );
}
- seq.setType( getType() );
+ try {
+ seq.setType( getType() );
+ }
+ catch ( final PhyloXmlDataFormatException e ) {
+ e.printStackTrace();
+ }
if ( getUris() != null ) {
seq.setUris( new ArrayList<Uri>() );
for( final Uri uri : getUris() ) {
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 );
_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 + "]" );
}
@Override
public PhylogenyData copy() {
final Taxonomy t = new Taxonomy();
- t.setTaxonomyCode( getTaxonomyCode() );
+ try {
+ t.setTaxonomyCode( getTaxonomyCode() );
+ }
+ catch ( final PhyloXmlDataFormatException e ) {
+ e.printStackTrace();
+ }
t.setScientificName( getScientificName() );
t.setCommonName( getCommonName() );
t.setAuthority( getAuthority() );
else {
t.setIdentifier( null );
}
- t.setRank( new String( getRank() ) );
+ try {
+ t.setRank( new String( getRank() ) );
+ }
+ catch ( final PhyloXmlDataFormatException e ) {
+ e.printStackTrace();
+ }
if ( getUris() != null ) {
t.setUris( new ArrayList<Uri>() );
for( final Uri uri : getUris() ) {
setScientificName( "" );
setCommonName( "" );
setIdentifier( null );
- setRank( "" );
- setTaxonomyCode( "" );
+ try {
+ setRank( "" );
+ }
+ catch ( final PhyloXmlDataFormatException e ) {
+ e.printStackTrace();
+ }
+ try {
+ setTaxonomyCode( "" );
+ }
+ catch ( final PhyloXmlDataFormatException e ) {
+ e.printStackTrace();
+ }
setAuthority( "" );
setSynonyms( null );
setUris( null );
_identifier = identifier;
}
- public void setRank( final String rank ) {
+ public void setRank( final String rank ) throws PhyloXmlDataFormatException {
if ( !ForesterUtil.isEmpty( rank ) && !PhyloXmlUtil.TAXONOMY_RANKS_SET.contains( rank ) ) {
throw new PhyloXmlDataFormatException( "illegal rank: [" + rank + "]" );
}
_synonyms = synonyms;
}
- public void setTaxonomyCode( final String taxonomy_code ) {
+ public void setTaxonomyCode( final String taxonomy_code ) throws PhyloXmlDataFormatException {
if ( !ForesterUtil.isEmpty( taxonomy_code )
&& !PhyloXmlUtil.TAXOMONY_CODE_PATTERN.matcher( taxonomy_code ).matches() ) {
throw new PhyloXmlDataFormatException( "illegal taxonomy code: [" + taxonomy_code + "]" );
}
}
if ( _strip_species_tree ) {
- for( PhylogenyNode x : _mapped_species_tree_nodes ) {
+ for( final PhylogenyNode x : _mapped_species_tree_nodes ) {
System.out.println( ">>" + x );
}
for( final PhylogenyNode s : species_tree_ext_nodes ) {
System.out.println();
}
}
- for( PhylogenyNode x : _mapped_species_tree_nodes ) {
+ for( final PhylogenyNode x : _mapped_species_tree_nodes ) {
System.out.println( ">>" + x );
}
}
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;
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++;
}
private static boolean testUniprotTaxonomySearch() {
try {
- List<UniProtTaxonomy> results = SequenceDbWsTools
- .getTaxonomiesFromCommonNameStrict( "starlet sea anemone", 10 );
+ List<UniProtTaxonomy> results = SequenceDbWsTools.getTaxonomiesFromCommonNameStrict( "starlet sea anemone",
+ 10 );
if ( results.size() != 1 ) {
return false;
}
}
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() );
}
//
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() );
}
//
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() );
}
//
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() );
}
//
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() );
}
//
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() );
}
//
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() );
}
//
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() );
if ( id != null ) {
return false;
}
-
// lcl_91970_unknown_
}
catch ( final Exception e ) {
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;
final Map<String, Map<String, String>> 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();
* @param picky
* @throws IllegalArgumentException
* @throws NHXFormatException
+ * @throws PhyloXmlDataFormatException
*/
public static void decorate( final Phylogeny phylogeny,
final Map<String, String> map,
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,
* @param intermediate_map
* maps name (in phylogeny) to a intermediate value
* @throws IllegalArgumentException
+ * @throws PhyloXmlDataFormatException
*/
public static void decorate( final Phylogeny phylogeny,
final Map<String, String> map,
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" );
}
final Map<String, Map<String, String>> 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,
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,
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,
private final static String LINE_SEPARATOR = ForesterUtil.LINE_SEPARATOR;
- public EasyWriter( BufferedWriter out ) {
+ public EasyWriter( final BufferedWriter out ) {
super( out );
}
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";
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
\r
public final class SequenceIdParser {\r
\r
- \r
- \r
// gb_ADF31344_1_segmented_worms_\r
// gb_AAA96518_1\r
// gb_EHB07727_1_rodents_\r
// mites|ref_XP_002434188_1\r
// ref_XP_002434188_1_mites___ticks_\r
// ref_NP_001121530_1_frogs___toads_\r
- \r
//The format for GenBank Accession numbers are:\r
//Nucleotide: 1 letter + 5 numerals OR 2 letters + 6 numerals\r
//Protein: 3 letters + 5 numerals\r
.compile( "(?:\\A|.*[^a-zA-Z0-9])([A-Z]{2}\\d{6})(?:[^a-zA-Z0-9]|\\Z)" );\r
private final static Pattern GENBANK_PROTEIN_AC_PATTERN = Pattern\r
.compile( "(?:\\A|.*[^a-zA-Z0-9])([A-Z]{3}\\d{5})(?:[^a-zA-Z0-9]|\\Z)" );\r
- \r
// RefSeq accession numbers can be distinguished from GenBank accessions \r
// by their distinct prefix format of 2 characters followed by an\r
// underscore character ('_'). For example, a RefSeq protein accession is NP_015325. \r
- private final static Pattern REFSEQ_PATTERN = Pattern\r
- .compile( "(?:\\A|.*[^a-zA-Z0-9])([A-Z]{2}_\\d{6,})(?:[^a-zA-Z0-9]|\\Z)" );\r
+ private final static Pattern REFSEQ_PATTERN = Pattern\r
+ .compile( "(?:\\A|.*[^a-zA-Z0-9])([A-Z]{2}_\\d{6,})(?:[^a-zA-Z0-9]|\\Z)" );\r
\r
- \r
- \r
/**\r
* Returns null if no match.\r
* \r
public final static Identifier parse( final String s ) {\r
String v = parseGenbankAccessor( s );\r
if ( !ForesterUtil.isEmpty( v ) ) {\r
-\r
return new Identifier( v, Identifier.NCBI );\r
}\r
v = parseRefSeqAccessor( s );\r
}\r
return null;\r
}\r
- \r
+\r
/**\r
* Returns null if no match.\r
* \r
}\r
}\r
}\r
- \r
+\r
/**\r
* Returns null if no match.\r
* \r
*/\r
private final static String parseRefSeqAccessor( final String query ) {\r
- Matcher m = REFSEQ_PATTERN.matcher( query );\r
+ final Matcher m = REFSEQ_PATTERN.matcher( query );\r
if ( m.lookingAt() ) {\r
return m.group( 1 );\r
}\r
return null;\r
}\r
- \r
- \r
- \r
+\r
private SequenceIdParser() {\r
// Hiding the constructor.\r
}\r
- \r
- \r
- \r
}\r
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 );
throw new CloneNotSupportedException();
}
-
public static SequenceDatabaseEntry createInstanceFromPlainTextForRefSeq( final List<String> 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" ) );
}
else {
e.setDe( DatabaseTools.extract( line, "DEFINITION" ) );
}
-
-
}
-
else if ( line.startsWith( "SOURCE" ) ) {
if ( line.indexOf( "(" ) > 0 ) {
e.setOs( DatabaseTools.extract( line, "SOURCE", "(" ) );
e.setOs( DatabaseTools.extract( line, "SOURCE" ) );
}
}
-
}
return e;
}
-
-
-
+
public static SequenceDatabaseEntry createInstanceFromPlainText( final List<String> lines ) {
final EbiDbEntry e = new EbiDbEntry();
for( final String line : lines ) {
-
if ( line.startsWith( "PA" ) ) {
e.setPA( DatabaseTools.extract( line, "PA" ) );
}
public String getProvider() {
return _provider;
}
-
+
public void setProvider( final String provider ) {
- _provider = provider;
+ _provider = provider;
}
}
public boolean isEmpty();
public String getAccession();
-
+
public String getProvider();
public String getSequenceName();
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
}
public static List<String> 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() );
public static SequenceDatabaseEntry obtainEmblEntry( final Identifier id, final int max_lines_to_return )
throws IOException {
- final List<String> lines = queryEmblDb( id , max_lines_to_return );
+ final List<String> lines = queryEmblDb( id, max_lines_to_return );
return EbiDbEntry.createInstanceFromPlainText( lines );
}
}
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 );
throw new CloneNotSupportedException();
}
-
public static SequenceDatabaseEntry createInstanceFromPlainTextForRefSeq( final List<String> 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" ) );
}
else {
e.setDe( DatabaseTools.extract( line, "DEFINITION" ) );
}
-
-
}
-
else if ( line.startsWith( "SOURCE" ) ) {
if ( line.indexOf( "(" ) > 0 ) {
e.setOs( DatabaseTools.extract( line, "SOURCE", "(" ) );
e.setOs( DatabaseTools.extract( line, "SOURCE" ) );
}
}
-
}
return e;
}
-
-
-
+
public static SequenceDatabaseEntry createInstanceFromPlainText( final List<String> lines ) {
final EbiDbEntry e = new EbiDbEntry();
for( final String line : lines ) {
-
if ( line.startsWith( "PA" ) ) {
e.setPA( DatabaseTools.extract( line, "PA" ) );
}
public String getProvider() {
return _provider;
}
-
+
public void setProvider( final String provider ) {
- _provider = provider;
+ _provider = provider;
}
}
public boolean isEmpty();
public String getAccession();
-
+
public String getProvider();
public String getSequenceName();
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
}
public static List<String> 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() );
public static SequenceDatabaseEntry obtainEmblEntry( final Identifier id, final int max_lines_to_return )
throws IOException {
- final List<String> lines = queryEmblDb( id , max_lines_to_return );
+ final List<String> lines = queryEmblDb( id, max_lines_to_return );
return EbiDbEntry.createInstanceFromPlainText( lines );
}
}