.equalsIgnoreCase( "uniprotkb" ) ) ) );
}
- synchronized public static SortedSet<String> obtainDetailedTaxonomicInformation( final Phylogeny phy )
+ synchronized public static SortedSet<String> obtainDetailedTaxonomicInformation( final Phylogeny phy,
+ final boolean delete )
throws IOException {
clearCachesIfTooLarge();
final SortedSet<String> not_found = new TreeSet<String>();
+ List<PhylogenyNode> not_found_external_nodes = null;
+ if ( delete ) {
+ not_found_external_nodes = new ArrayList<PhylogenyNode>();
+ }
for( final PhylogenyNodeIterator iter = phy.iteratorPostorder(); iter.hasNext(); ) {
final PhylogenyNode node = iter.next();
final QUERY_TYPE qt = null;
else {
not_found.add( node.toString() );
}
+ if ( delete ) {
+ not_found_external_nodes.add( node );
+ }
}
UniProtTaxonomy up_tax = null;
if ( ( tax != null )
}
else {
not_found.add( tax.toString() );
+ if ( delete && node.isExternal() ) {
+ not_found_external_nodes.add( node );
+ }
}
}
}
+ if ( delete ) {
+ for( PhylogenyNode node : not_found_external_nodes ) {
+ phy.deleteSubtree( node, false );
+ }
+ phy.recalculateNumberOfExternalDescendants( true );
+ }
return not_found;
}
final SortedSet<String> all_chars = getAllExternalPresentAndGainedCharacters( phy.getRoot() );
System.out.println( "Sum of all external characters:\t" + all_chars.size() );
System.out.println();
+ final boolean SIMPLE = false;
for( final PhylogenyNodeIterator iter = phy.iteratorPostorder(); iter.hasNext(); ) {
final PhylogenyNode node = iter.next();
+ if ( !SIMPLE && node.isExternal() ) {
+ continue;
+ }
if ( !node.isRoot() ) {
System.out.println();
if ( node.getNodeData().isHasTaxonomy()
final SortedSet<String> unique_chars = new TreeSet<String>();
for( final String node_char : node_chars ) {
if ( !not_node_chars.contains( node_char ) ) {
- unique_chars.add( node_char );
+ if ( SIMPLE ) {
+ unique_chars.add( node_char );
+ }
+ else {
+ boolean found = true;
+ for( final int external_id : external_ids ) {
+ if ( !phy.getNode( external_id ).getNodeData().getBinaryCharacters()
+ .getGainedCharacters().contains( node_char )
+ && !phy.getNode( external_id ).getNodeData().getBinaryCharacters()
+ .getPresentCharacters().contains( node_char ) ) {
+ found = false;
+ break;
+ }
+ }
+ if ( found ) {
+ unique_chars.add( node_char );
+ }
+ }
}
}
System.out.println( "\tSUM:\t" + unique_chars.size() );
JMenuItem _collapse_species_specific_subtrees;
JMenuItem _collapse_below_threshold; //TODO implememt me
JMenuItem _obtain_detailed_taxonomic_information_jmi;
+ JMenuItem _obtain_detailed_taxonomic_information_deleting_jmi;
JMenuItem _obtain_uniprot_seq_information_jmi;
JMenuItem _move_node_names_to_tax_sn_jmi;
JMenuItem _move_node_names_to_seq_names_jmi;
}
obtainDetailedTaxonomicInformation();
}
+ else if ( o == _obtain_detailed_taxonomic_information_deleting_jmi ) {
+ if ( isSubtreeDisplayed() ) {
+ return;
+ }
+ obtainDetailedTaxonomicInformationDelete();
+ }
else if ( o == _obtain_uniprot_seq_information_jmi ) {
obtainUniProtSequenceInformation();
}
_obtain_detailed_taxonomic_information_jmi
.setToolTipText( "To add additional taxonomic information (from UniProt Taxonomy)" );
_tools_menu
+ .add( _obtain_detailed_taxonomic_information_deleting_jmi = new JMenuItem( "Obtain Detailed Taxonomic Information (Delete Nodes)" ) );
+ customizeJMenuItem( _obtain_detailed_taxonomic_information_deleting_jmi );
+ _obtain_detailed_taxonomic_information_deleting_jmi
+ .setToolTipText( "To add additional taxonomic information, deletes nodes for which taxonomy cannot found (from UniProt Taxonomy)" );
+ _tools_menu
.add( _obtain_uniprot_seq_information_jmi = new JMenuItem( "Obtain Sequence Information (from UniProt)" ) );
customizeJMenuItem( _obtain_uniprot_seq_information_jmi );
_obtain_uniprot_seq_information_jmi.setToolTipText( "To add additional sequence information (from UniProt)" );
}
}
+ private void obtainDetailedTaxonomicInformationDelete() {
+ if ( getCurrentTreePanel() != null ) {
+ final Phylogeny phy = getCurrentTreePanel().getPhylogeny();
+ if ( ( phy != null ) && !phy.isEmpty() ) {
+ final TaxonomyDataObtainer t = new TaxonomyDataObtainer( this,
+ _mainpanel.getCurrentTreePanel(),
+ phy.copy(),
+ true );
+ new Thread( t ).start();
+ }
+ }
+ }
+
private void obtainUniProtSequenceInformation() {
if ( getCurrentTreePanel() != null ) {
final Phylogeny phy = getCurrentTreePanel().getPhylogeny();
private final Phylogeny _phy;
private final MainFrameApplication _mf;
private final TreePanel _treepanel;
+ private final boolean _delete;
+
+ public TaxonomyDataObtainer( final MainFrameApplication mf,
+ final TreePanel treepanel,
+ final Phylogeny phy,
+ boolean delete ) {
+ _phy = phy;
+ _mf = mf;
+ _treepanel = treepanel;
+ _delete = delete;
+ }
public TaxonomyDataObtainer( final MainFrameApplication mf, final TreePanel treepanel, final Phylogeny phy ) {
_phy = phy;
_mf = mf;
_treepanel = treepanel;
+ _delete = false;
}
private String getBaseUrl() {
_mf.getMainPanel().getCurrentTreePanel().setWaitCursor();
SortedSet<String> not_found = null;
try {
- not_found = AncestralTaxonomyInference.obtainDetailedTaxonomicInformation( _phy );
+ not_found = AncestralTaxonomyInference.obtainDetailedTaxonomicInformation( _phy, _delete );
}
catch ( final UnknownHostException e ) {
_mf.getMainPanel().getCurrentTreePanel().setArrowCursor();
final StringBuffer sb = new StringBuffer();
sb.append( "Not all taxonomies could be resolved.\n" );
if ( not_found.size() == 1 ) {
- sb.append( "The following taxonomy was not found:\n" );
+ if ( _delete ) {
+ sb.append( "The following taxonomy was not found and deleted (if external):\n" );
+ }
+ else {
+ sb.append( "The following taxonomy was not found:\n" );
+ }
}
else {
- sb.append( "The following taxonomies were not found (total: " + not_found.size() + "):\n" );
+ if ( _delete ) {
+ sb.append( "The following taxonomies were not found and deleted (if external) (total: "
+ + not_found.size() + "):\n" );
+ }
+ else {
+ sb.append( "The following taxonomies were not found (total: " + not_found.size() + "):\n" );
+ }
}
int i = 0;
for( final String string : not_found ) {