if ( !ForesterUtil.isEmpty( stats.get( i ).getDescription() ) ) {\r
if ( !stats.get( i ).getDescription().equalsIgnoreCase( c.getType() ) ) {\r
throw new IllegalArgumentException( "support values in node [" + n.toString()\r
- + "] appear inconsistently ordered" );\r
+ + "] appear inconsistently ordered" );\r
}\r
}\r
stats.get( i ).setDescription( c.getType() );\r
\r
/**\r
* Calculates the distance between PhylogenyNodes node1 and node2.\r
- * \r
- * \r
+ *\r
+ *\r
* @param node1\r
* @param node2\r
* @return distance between node1 and node2\r
\r
/**\r
* Returns the LCA of PhylogenyNodes node1 and node2.\r
- * \r
- * \r
+ *\r
+ *\r
* @param node1\r
* @param node2\r
* @return LCA of node1 and node2\r
/**\r
* Returns the LCA of PhylogenyNodes node1 and node2.\r
* Precondition: ids are in pre-order (or level-order).\r
- * \r
- * \r
+ *\r
+ *\r
* @param node1\r
* @param node2\r
* @return LCA of node1 and node2\r
}\r
\r
/**\r
- * \r
+ *\r
* Convenience method\r
- * \r
+ *\r
* @param node\r
* @return\r
*/\r
}\r
\r
/**\r
- * Returns taxonomy t if all external descendants have \r
+ * Returns taxonomy t if all external descendants have\r
* the same taxonomy t, null otherwise.\r
- * \r
+ *\r
*/\r
public static Taxonomy getExternalDescendantsTaxonomy( final PhylogenyNode node ) {\r
final List<PhylogenyNode> descs = node.getAllExternalDescendants();\r
\r
/*\r
* This is case insensitive.\r
- * \r
+ *\r
*/\r
public synchronized static boolean isTaxonomyHasIdentifierOfGivenProvider( final Taxonomy tax,\r
final String[] providers ) {\r
* all external nodes of node.\r
* If at least one of the external nodes has no taxonomy,\r
* null is returned.\r
- * \r
+ *\r
*/\r
public static Map<Taxonomy, Integer> obtainDistinctTaxonomyCounts( final PhylogenyNode node ) {\r
final List<PhylogenyNode> descs = node.getAllExternalDescendants();\r
* Arranges the order of childern for each node of this Phylogeny in such a\r
* way that either the branch with more children is on top (right) or on\r
* bottom (left), dependent on the value of boolean order.\r
- * \r
+ *\r
* @param order\r
* decides in which direction to order\r
- * @param pri \r
+ * @param pri\r
*/\r
public static void orderAppearance( final PhylogenyNode n,\r
final boolean order,\r
}\r
}\r
\r
+ \r
+ private static enum NDF {\r
+ NN( "NN" ),\r
+ TC( "TC" ),\r
+ CN( "CN" ),\r
+ TS( "TS" ),\r
+ TI( "TI" ),\r
+ SY( "SY" ),\r
+ SN( "SN" ),\r
+ GN( "GN" ),\r
+ SS( "SS" ),\r
+ SA( "SA" ),\r
+ DO( "DO" ),\r
+ AN( "AN" ),\r
+ XR( "XR" ),\r
+ BC( "BC" ),\r
+ MS( "MS" );\r
+ \r
+ private final String _text;\r
+\r
+ NDF( final String text ) {\r
+ _text = text;\r
+ }\r
+\r
+ public static NDF fromString( final String text ) {\r
+ for( NDF n : NDF.values() ) {\r
+ if ( text.startsWith( n._text ) ) {\r
+ return n;\r
+ }\r
+ }\r
+ return null;\r
+ }\r
+ }\r
+ \r
+ \r
public static List<PhylogenyNode> searchData( final String query,\r
final Phylogeny phy,\r
final boolean case_sensitive,\r
final boolean partial,\r
final boolean regex,\r
- final boolean search_domains ) {\r
+ final boolean search_domains,\r
+ final double domains_confidence_threshold ) {\r
final List<PhylogenyNode> nodes = new ArrayList<PhylogenyNode>();\r
if ( phy.isEmpty() || ( query == null ) ) {\r
return nodes;\r
if ( ForesterUtil.isEmpty( query ) ) {\r
return nodes;\r
}\r
+\r
+ String my_query = query;\r
+ NDF ndf = null;\r
+\r
+ if ( my_query.length() > 2 && my_query.indexOf( ":" ) == 2 ) {\r
+ ndf = NDF.fromString( my_query );\r
+ if ( ndf != null ) {\r
+ my_query = my_query.substring( 3 );\r
+ }\r
+ }\r
+ \r
+ \r
for( final PhylogenyNodeIterator iter = phy.iteratorPreorder(); iter.hasNext(); ) {\r
final PhylogenyNode node = iter.next();\r
boolean match = false;\r
- if ( match( node.getName(), query, case_sensitive, partial, regex ) ) {\r
+ \r
+ \r
+ if ( ( ndf == null || ndf == NDF.NN ) && match( node.getName(), my_query, case_sensitive, partial, regex ) ) {\r
match = true;\r
}\r
- else if ( node.getNodeData().isHasTaxonomy()\r
- && match( node.getNodeData().getTaxonomy().getTaxonomyCode(), query, case_sensitive, partial, regex ) ) {\r
+ else if ( ( ndf == null || ndf == NDF.TC ) && node.getNodeData().isHasTaxonomy()\r
+ && match( node.getNodeData().getTaxonomy().getTaxonomyCode(), my_query, case_sensitive, partial, regex ) ) {\r
match = true;\r
}\r
- else if ( node.getNodeData().isHasTaxonomy()\r
- && match( node.getNodeData().getTaxonomy().getCommonName(), query, case_sensitive, partial, regex ) ) {\r
+ else if ( ( ndf == null || ndf == NDF.CN ) && node.getNodeData().isHasTaxonomy()\r
+ && match( node.getNodeData().getTaxonomy().getCommonName(), my_query, case_sensitive, partial, regex ) ) {\r
match = true;\r
}\r
- else if ( node.getNodeData().isHasTaxonomy()\r
+ else if ( ( ndf == null || ndf == NDF.TS ) && node.getNodeData().isHasTaxonomy()\r
&& match( node.getNodeData().getTaxonomy().getScientificName(),\r
- query,\r
+ my_query,\r
case_sensitive,\r
partial,\r
regex ) ) {\r
match = true;\r
}\r
- else if ( node.getNodeData().isHasTaxonomy()\r
+ else if ( ( ndf == null || ndf == NDF.TI ) &&\r
+ node.getNodeData().isHasTaxonomy()\r
&& ( node.getNodeData().getTaxonomy().getIdentifier() != null )\r
&& match( node.getNodeData().getTaxonomy().getIdentifier().getValue(),\r
- query,\r
+ my_query,\r
case_sensitive,\r
partial,\r
regex ) ) {\r
match = true;\r
}\r
- else if ( node.getNodeData().isHasTaxonomy() && !node.getNodeData().getTaxonomy().getSynonyms().isEmpty() ) {\r
+ else if ( \r
+ ( ndf == null || ndf == NDF.SY ) &&\r
+ node.getNodeData().isHasTaxonomy() && !node.getNodeData().getTaxonomy().getSynonyms().isEmpty() ) {\r
final List<String> syns = node.getNodeData().getTaxonomy().getSynonyms();\r
I: for( final String syn : syns ) {\r
- if ( match( syn, query, case_sensitive, partial, regex ) ) {\r
+ if ( match( syn, my_query, case_sensitive, partial, regex ) ) {\r
match = true;\r
break I;\r
}\r
}\r
}\r
- if ( !match && node.getNodeData().isHasSequence()\r
- && match( node.getNodeData().getSequence().getName(), query, case_sensitive, partial, regex ) ) {\r
+ if ( !match && ( ndf == null || ndf == NDF.SN ) &&\r
+ node.getNodeData().isHasSequence()\r
+ && match( node.getNodeData().getSequence().getName(), my_query, case_sensitive, partial, regex ) ) {\r
match = true;\r
}\r
- if ( !match && node.getNodeData().isHasSequence()\r
- && match( node.getNodeData().getSequence().getGeneName(), query, case_sensitive, partial, regex ) ) {\r
+ if ( !match && ( ndf == null || ndf == NDF.GN ) &&\r
+ node.getNodeData().isHasSequence()\r
+ && match( node.getNodeData().getSequence().getGeneName(), my_query, case_sensitive, partial, regex ) ) {\r
match = true;\r
}\r
- if ( !match && node.getNodeData().isHasSequence()\r
- && match( node.getNodeData().getSequence().getSymbol(), query, case_sensitive, partial, regex ) ) {\r
+ if ( !match && ( ndf == null || ndf == NDF.SS ) &&\r
+ \r
+ node.getNodeData().isHasSequence()\r
+ && match( node.getNodeData().getSequence().getSymbol(), my_query, case_sensitive, partial, regex ) ) {\r
match = true;\r
}\r
- if ( !match\r
- && node.getNodeData().isHasSequence()\r
+ if ( !match && ( ndf == null || ndf == NDF.SA ) &&\r
+ \r
+ \r
+ node.getNodeData().isHasSequence()\r
&& ( node.getNodeData().getSequence().getAccession() != null )\r
&& match( node.getNodeData().getSequence().getAccession().getValue(),\r
- query,\r
+ my_query,\r
case_sensitive,\r
partial,\r
regex ) ) {\r
match = true;\r
}\r
- if ( search_domains && !match && node.getNodeData().isHasSequence()\r
+ if ( !match && ( (ndf == null && search_domains ) || ndf == NDF.DO ) && node.getNodeData().isHasSequence()\r
&& ( node.getNodeData().getSequence().getDomainArchitecture() != null ) ) {\r
final DomainArchitecture da = node.getNodeData().getSequence().getDomainArchitecture();\r
I: for( int i = 0; i < da.getNumberOfDomains(); ++i ) {\r
- if ( match( da.getDomain( i ).getName(), query, case_sensitive, partial, regex ) ) {\r
+ if ( ( da.getDomain( i ).getConfidence() <= domains_confidence_threshold ) && ( match( da.getDomain( i ).getName(), my_query, case_sensitive, partial, regex ) ) ) {\r
match = true;\r
break I;\r
}\r
}\r
}\r
- if ( !match && node.getNodeData().isHasSequence()\r
+ if ( \r
+ !match && ( ndf == null || ndf == NDF.AN ) &&\r
+ node.getNodeData().isHasSequence()\r
&& ( node.getNodeData().getSequence().getAnnotations() != null ) ) {\r
for( final Annotation ann : node.getNodeData().getSequence().getAnnotations() ) {\r
- if ( match( ann.getDesc(), query, case_sensitive, partial, regex ) ) {\r
+ if ( match( ann.getDesc(), my_query, case_sensitive, partial, regex ) ) {\r
match = true;\r
break;\r
}\r
- if ( match( ann.getRef(), query, case_sensitive, partial, regex ) ) {\r
+ if ( match( ann.getRef(), my_query, case_sensitive, partial, regex ) ) {\r
match = true;\r
break;\r
}\r
}\r
}\r
- if ( !match && node.getNodeData().isHasSequence()\r
+ if ( !match && ( ndf == null || ndf == NDF.XR ) &&\r
+ node.getNodeData().isHasSequence()\r
&& ( node.getNodeData().getSequence().getCrossReferences() != null ) ) {\r
for( final Accession x : node.getNodeData().getSequence().getCrossReferences() ) {\r
- if ( match( x.getComment(), query, case_sensitive, partial, regex ) ) {\r
+ if ( match( x.getComment(), my_query, case_sensitive, partial, regex ) ) {\r
match = true;\r
break;\r
}\r
- if ( match( x.getSource(), query, case_sensitive, partial, regex ) ) {\r
+ if ( match( x.getSource(), my_query, case_sensitive, partial, regex ) ) {\r
match = true;\r
break;\r
}\r
- if ( match( x.getValue(), query, case_sensitive, partial, regex ) ) {\r
+ if ( match( x.getValue(), my_query, case_sensitive, partial, regex ) ) {\r
match = true;\r
break;\r
}\r
}\r
}\r
//\r
- if ( !match && ( node.getNodeData().getBinaryCharacters() != null ) ) {\r
+ if ( !match && ( ndf == null || ndf == NDF.BC ) &&\r
+ ( node.getNodeData().getBinaryCharacters() != null ) ) {\r
Iterator<String> it = node.getNodeData().getBinaryCharacters().getPresentCharacters().iterator();\r
I: while ( it.hasNext() ) {\r
- if ( match( it.next(), query, case_sensitive, partial, regex ) ) {\r
+ if ( match( it.next(), my_query, case_sensitive, partial, regex ) ) {\r
match = true;\r
break I;\r
}\r
}\r
it = node.getNodeData().getBinaryCharacters().getGainedCharacters().iterator();\r
I: while ( it.hasNext() ) {\r
- if ( match( it.next(), query, case_sensitive, partial, regex ) ) {\r
+ if ( match( it.next(), my_query, case_sensitive, partial, regex ) ) {\r
match = true;\r
break I;\r
}\r
\r
/**\r
* Convenience method.\r
- * Sets value for the first confidence value (created if not present, values overwritten otherwise). \r
+ * Sets value for the first confidence value (created if not present, values overwritten otherwise).\r
*/\r
public static void setBootstrapConfidence( final PhylogenyNode node, final double bootstrap_confidence_value ) {\r
setConfidence( node, bootstrap_confidence_value, "bootstrap" );\r
\r
/**\r
* Convenience method.\r
- * Sets value for the first confidence value (created if not present, values overwritten otherwise). \r
+ * Sets value for the first confidence value (created if not present, values overwritten otherwise).\r
*/\r
public static void setConfidence( final PhylogenyNode node, final double confidence_value ) {\r
setConfidence( node, confidence_value, "" );\r
\r
/**\r
* Convenience method.\r
- * Sets value for the first confidence value (created if not present, values overwritten otherwise). \r
+ * Sets value for the first confidence value (created if not present, values overwritten otherwise).\r
*/\r
public static void setConfidence( final PhylogenyNode node, final double confidence_value, final String type ) {\r
Confidence c = null;\r
\r
/**\r
* Convenience method to set the taxonomy code of a phylogeny node.\r
- * \r
- * \r
+ *\r
+ *\r
* @param node\r
* @param taxonomy_code\r
- * @throws PhyloXmlDataFormatException \r
+ * @throws PhyloXmlDataFormatException\r
*/\r
public static void setTaxonomyCode( final PhylogenyNode node, final String taxonomy_code )\r
throws PhyloXmlDataFormatException {\r
/**\r
* Removes from Phylogeny to_be_stripped all external Nodes which are\r
* associated with a species NOT found in Phylogeny reference.\r
- * \r
+ *\r
* @param reference\r
* a reference Phylogeny\r
* @param to_be_stripped\r
else if ( !( ref_ext_taxo.contains( n.getNodeData().getTaxonomy().getScientificName() ) )\r
&& !( ref_ext_taxo.contains( n.getNodeData().getTaxonomy().getTaxonomyCode() ) )\r
&& !( ( n.getNodeData().getTaxonomy().getIdentifier() != null ) && ref_ext_taxo.contains( n\r
- .getNodeData().getTaxonomy().getIdentifier().getValuePlusProvider() ) ) ) {\r
+ .getNodeData().getTaxonomy().getIdentifier().getValuePlusProvider() ) ) ) {\r
nodes_to_delete.add( n );\r
}\r
}\r
n.setName( "" );\r
}\r
n.getNodeData().getTaxonomy()\r
- .setIdentifier( new Identifier( id, PhyloXmlUtil.UNIPROT_TAX_PROVIDER ) );\r
+ .setIdentifier( new Identifier( id, PhyloXmlUtil.UNIPROT_TAX_PROVIDER ) );\r
break;\r
}\r
case TAXONOMY_ID_UNIPROT_2: {\r
n.setName( "" );\r
}\r
n.getNodeData().getTaxonomy()\r
- .setIdentifier( new Identifier( id, PhyloXmlUtil.UNIPROT_TAX_PROVIDER ) );\r
+ .setIdentifier( new Identifier( id, PhyloXmlUtil.UNIPROT_TAX_PROVIDER ) );\r
break;\r
}\r
case TAXONOMY_ID: {\r
/**\r
* Calculates the distance between PhylogenyNodes n1 and n2.\r
* PRECONDITION: n1 is a descendant of n2.\r
- * \r
+ *\r
* @param n1\r
* a descendant of n2\r
* @param n2\r