// Copyright (C) 2008-2009 Christian M. Zmasek
// Copyright (C) 2008-2009 Burnham Institute for Medical Research
// All rights reserved
-//
+//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
-//
+//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
import java.util.regex.Matcher;
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;
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();
}
if ( new_values != null ) {
if ( new_values.containsKey( TP_TAXONOMY_CODE ) ) {
- ForesterUtil.ensurePresenceOfTaxonomy( node );
+ AptxUtil.ensurePresenceOfTaxonomy( node );
node.getNodeData().getTaxonomy().setTaxonomyCode( new_values.get( TP_TAXONOMY_CODE ) );
}
if ( new_values.containsKey( TP_TAXONOMY_ID )
&& new_values.containsKey( TP_TAXONOMY_ID_PROVIDER ) ) {
- ForesterUtil.ensurePresenceOfTaxonomy( node );
- node.getNodeData().getTaxonomy().setIdentifier( new Identifier( new_values
- .get( TP_TAXONOMY_ID ), new_values.get( TP_TAXONOMY_ID_PROVIDER ) ) );
+ AptxUtil.ensurePresenceOfTaxonomy( node );
+ node.getNodeData()
+ .getTaxonomy()
+ .setIdentifier( new Identifier( new_values.get( TP_TAXONOMY_ID ),
+ new_values.get( TP_TAXONOMY_ID_PROVIDER ) ) );
}
else if ( new_values.containsKey( TP_TAXONOMY_ID ) ) {
- ForesterUtil.ensurePresenceOfTaxonomy( node );
- node.getNodeData().getTaxonomy().setIdentifier( new Identifier( new_values
- .get( TP_TAXONOMY_ID ) ) );
+ AptxUtil.ensurePresenceOfTaxonomy( node );
+ node.getNodeData().getTaxonomy()
+ .setIdentifier( new Identifier( new_values.get( TP_TAXONOMY_ID ) ) );
}
if ( new_values.containsKey( TP_TAXONOMY_SN ) ) {
- ForesterUtil.ensurePresenceOfTaxonomy( node );
+ AptxUtil.ensurePresenceOfTaxonomy( node );
node.getNodeData().getTaxonomy().setScientificName( new_values.get( TP_TAXONOMY_SN ) );
}
if ( new_values.containsKey( TP_TAXONOMY_CN ) ) {
- ForesterUtil.ensurePresenceOfTaxonomy( node );
+ AptxUtil.ensurePresenceOfTaxonomy( node );
node.getNodeData().getTaxonomy().setCommonName( new_values.get( TP_TAXONOMY_CN ) );
}
if ( new_values.containsKey( TP_TAXONOMY_SYN ) ) {
- ForesterUtil.ensurePresenceOfTaxonomy( node );
+ AptxUtil.ensurePresenceOfTaxonomy( node );
node.getNodeData().getTaxonomy().getSynonyms().add( new_values.get( TP_TAXONOMY_SYN ) );
}
if ( new_values.containsKey( TP_SEQ_ACCESSION )
&& new_values.containsKey( TP_SEQ_ACCESSION_SOURCE ) ) {
- ForesterUtil.ensurePresenceOfSequence( node );
- node.getNodeData().getSequence().setAccession( new Accession( new_values
- .get( TP_SEQ_ACCESSION ), new_values.get( TP_SEQ_ACCESSION_SOURCE ) ) );
+ AptxUtil.ensurePresenceOfSequence( node );
+ node.getNodeData()
+ .getSequence()
+ .setAccession( new Accession( new_values.get( TP_SEQ_ACCESSION ),
+ new_values.get( TP_SEQ_ACCESSION_SOURCE ) ) );
}
if ( new_values.containsKey( TP_SEQ_ANNOTATION_DESC ) ) {
- ForesterUtil.ensurePresenceOfSequence( node );
+ AptxUtil.ensurePresenceOfSequence( node );
final Annotation ann = new Annotation( "?" );
ann.setDesc( new_values.get( TP_SEQ_ANNOTATION_DESC ) );
node.getNodeData().getSequence().addAnnotation( ann );
}
if ( new_values.containsKey( TP_SEQ_ANNOTATION_REF ) ) {
- ForesterUtil.ensurePresenceOfSequence( node );
+ AptxUtil.ensurePresenceOfSequence( node );
final Annotation ann = new Annotation( new_values.get( TP_SEQ_ANNOTATION_REF ) );
node.getNodeData().getSequence().addAnnotation( ann );
}
if ( new_values.containsKey( TP_SEQ_SYMBOL ) ) {
- ForesterUtil.ensurePresenceOfSequence( node );
+ AptxUtil.ensurePresenceOfSequence( node );
node.getNodeData().getSequence().setSymbol( new_values.get( TP_SEQ_SYMBOL ) );
}
if ( new_values.containsKey( TP_SEQ_NAME ) ) {
- ForesterUtil.ensurePresenceOfSequence( node );
+ AptxUtil.ensurePresenceOfSequence( node );
node.getNodeData().getSequence().setName( new_values.get( TP_SEQ_NAME ) );
}
if ( new_values.containsKey( TP_SEQ_MOL_SEQ ) ) {
- ForesterUtil.ensurePresenceOfSequence( node );
+ AptxUtil.ensurePresenceOfSequence( node );
node.getNodeData().getSequence().setMolecularSequence( new_values.get( TP_SEQ_MOL_SEQ ) );
}
if ( new_values.containsKey( TP_NODE_NAME ) ) {
node.setName( new_values.get( TP_NODE_NAME ) );
}
- }
- }
+ } // if ( new_values != null )
+ } // if ( map.containsKey( name ) || ( numbers_of_chars_allowed_to_remove_if_not_found_in_map > 0 ) )
else if ( picky ) {
throw new IllegalArgumentException( "\"" + name + "\" not found in name map" );
}
* @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" );
}
if ( PhylogenyDecorator.VERBOSE ) {
System.out.println( name + ": " + new_value );
}
- ForesterUtil.ensurePresenceOfTaxonomy( node );
+ AptxUtil.ensurePresenceOfTaxonomy( node );
node.getNodeData().getTaxonomy().setTaxonomyCode( new_value );
break;
case TAXONOMY_SCIENTIFIC_NAME:
if ( PhylogenyDecorator.VERBOSE ) {
System.out.println( name + ": " + new_value );
}
- ForesterUtil.ensurePresenceOfTaxonomy( node );
+ AptxUtil.ensurePresenceOfTaxonomy( node );
node.getNodeData().getTaxonomy().setScientificName( new_value );
break;
case SEQUENCE_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 static void extractBracketedScientificNames( final PhylogenyNode node, final String new_value ) {
final int i = new_value.lastIndexOf( "[" );
final String scientific_name = new_value.substring( i + 1, new_value.length() - 1 );
- ForesterUtil.ensurePresenceOfTaxonomy( node );
+ AptxUtil.ensurePresenceOfTaxonomy( node );
node.getNodeData().getTaxonomy().setScientificName( scientific_name );
}