if ( last_common_lineage.isEmpty() ) {
boolean saw_viruses = false;
boolean saw_cellular_organism = false;
+ boolean saw_x = false;
for( final String[] lineage : lineages ) {
if ( lineage.length > 0 ) {
if ( lineage[ 0 ].equalsIgnoreCase( UniProtTaxonomy.VIRUSES ) ) {
else if ( lineage[ 0 ].equalsIgnoreCase( UniProtTaxonomy.CELLULAR_ORGANISMS ) ) {
saw_cellular_organism = true;
}
- if ( saw_cellular_organism && saw_viruses ) {
+ else if ( lineage[ 0 ].equalsIgnoreCase( UniProtTaxonomy.X ) ) {
+ saw_x = true;
+ }
+ if ( ( saw_cellular_organism && saw_viruses ) || saw_x ) {
break;
}
}
}
- if ( saw_cellular_organism && saw_viruses ) {
- //last_common_lineage.add( UniProtTaxonomy.CELLULAR_ORGANISMS );
- // last_common = UniProtTaxonomy.CELLULAR_ORGANISMS;
+ if ( ( saw_cellular_organism && saw_viruses ) || saw_x ) {
+ last_common_lineage.add( UniProtTaxonomy.X );
+ last_common = UniProtTaxonomy.X;
}
else {
String msg = "no common lineage for:\n";
}
private final static List<UniProtTaxonomy> getTaxonomiesFromScientificName( final String query ) throws IOException {
- if ( query.equalsIgnoreCase( UniProtTaxonomy.BACTERIA ) ||
- query.equalsIgnoreCase( UniProtTaxonomy.ARCHAEA ) ||
- query.equalsIgnoreCase( UniProtTaxonomy.VIRUSES ) ||
- query.equalsIgnoreCase( UniProtTaxonomy.EUKARYOTA )
- ) {
+ if ( query.equalsIgnoreCase( UniProtTaxonomy.BACTERIA ) || query.equalsIgnoreCase( UniProtTaxonomy.ARCHAEA )
+ || query.equalsIgnoreCase( UniProtTaxonomy.VIRUSES )
+ || query.equalsIgnoreCase( UniProtTaxonomy.EUKARYOTA ) || query.equalsIgnoreCase( UniProtTaxonomy.X ) ) {
final List<UniProtTaxonomy> l = new ArrayList<UniProtTaxonomy>();
l.add( UniProtTaxonomy.createSpecialFromScientificName( query ) );
return l;
}
-
return SequenceDbWsTools.getTaxonomiesFromScientificNameStrict( query, MAX_TAXONOMIES_TO_RETURN );
}
import java.awt.Color;
import java.util.List;
+import java.util.Map;
import java.util.SortedMap;
import java.util.SortedSet;
addSubelement( category,
"External children",
String.valueOf( phylogeny_node.getAllExternalDescendants().size() ) );
- final SortedMap<Taxonomy, Integer> distinct_tax = PhylogenyMethods
- .obtainDistinctTaxonomyCounts( phylogeny_node );
+ final Map<Taxonomy, Integer> distinct_tax = PhylogenyMethods.obtainDistinctTaxonomyCounts( phylogeny_node );
if ( distinct_tax != null ) {
final int no_tax = PhylogenyMethods.calculateNumberOfExternalNodesWithoutTaxonomy( phylogeny_node );
final int tax_count = distinct_tax.size();
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import java.util.Set;
-import java.util.SortedMap;
-import java.util.TreeMap;
import org.forester.io.parsers.PhylogenyParser;
import org.forester.io.parsers.phyloxml.PhyloXmlDataFormatException;
* null is returned.
*
*/
- public static SortedMap<Taxonomy, Integer> obtainDistinctTaxonomyCounts( final PhylogenyNode node ) {
+ public static Map<Taxonomy, Integer> obtainDistinctTaxonomyCounts( final PhylogenyNode node ) {
final List<PhylogenyNode> descs = node.getAllExternalDescendants();
- final SortedMap<Taxonomy, Integer> tax_map = new TreeMap<Taxonomy, Integer>();
+ final Map<Taxonomy, Integer> tax_map = new HashMap<Taxonomy, Integer>();
for( final PhylogenyNode n : descs ) {
if ( !n.getNodeData().isHasTaxonomy() || n.getNodeData().getTaxonomy().isEmpty() ) {
return null;
public boolean isEmpty() {
return ( ( getIdentifier() == null ) && ForesterUtil.isEmpty( getTaxonomyCode() )
- && ForesterUtil.isEmpty( getCommonName() ) && ForesterUtil.isEmpty( getScientificName() )
- && ForesterUtil.isEmpty( getRank() ) && ForesterUtil.isEmpty( _uris )
- && ForesterUtil.isEmpty( getAuthority() ) && ForesterUtil.isEmpty( _synonyms ) && ForesterUtil
+ && ForesterUtil.isEmpty( getCommonName() ) && ForesterUtil.isEmpty( getScientificName() ) && ForesterUtil
.isEmpty( _lineage ) );
}
else if ( !ForesterUtil.isEmpty( getCommonName() ) && !ForesterUtil.isEmpty( tax.getCommonName() ) ) {
return getCommonName().equalsIgnoreCase( tax.getCommonName() );
}
- else if ( !ForesterUtil.isEmpty( getScientificName() ) && !ForesterUtil.isEmpty( tax.getCommonName() ) ) {
- return getScientificName().equalsIgnoreCase( tax.getCommonName() );
- }
- else if ( !ForesterUtil.isEmpty( getCommonName() ) && !ForesterUtil.isEmpty( tax.getScientificName() ) ) {
- return getCommonName().equalsIgnoreCase( tax.getScientificName() );
- }
- throw new RuntimeException( "comparison not possible with empty fields" );
+ //throw new RuntimeException( "comparison not possible with empty fields" );
+ return false;
}
public void setAuthority( final String authority ) {
if ( equals( o ) ) {
return 0;
}
- else if ( !ForesterUtil.isEmpty( getScientificName() ) && !ForesterUtil.isEmpty( o.getScientificName() ) ) {
+ if ( ( getIdentifier() != null ) && ( o.getIdentifier() != null )
+ && !ForesterUtil.isEmpty( getIdentifier().getValue() )
+ && !ForesterUtil.isEmpty( o.getIdentifier().getValue() ) ) {
+ final int x = getIdentifier().getValuePlusProvider().compareTo( o.getIdentifier().getValuePlusProvider() );
+ if ( x != 0 ) {
+ return x;
+ }
+ }
+ if ( !ForesterUtil.isEmpty( getScientificName() ) && !ForesterUtil.isEmpty( o.getScientificName() ) ) {
return getScientificName().compareToIgnoreCase( o.getScientificName() );
}
- else if ( !ForesterUtil.isEmpty( getCommonName() ) && !ForesterUtil.isEmpty( o.getCommonName() ) ) {
+ if ( !ForesterUtil.isEmpty( getCommonName() ) && !ForesterUtil.isEmpty( o.getCommonName() ) ) {
return getCommonName().compareToIgnoreCase( o.getCommonName() );
}
- else if ( !ForesterUtil.isEmpty( getTaxonomyCode() ) && !ForesterUtil.isEmpty( o.getTaxonomyCode() ) ) {
+ if ( !ForesterUtil.isEmpty( getTaxonomyCode() ) && !ForesterUtil.isEmpty( o.getTaxonomyCode() ) ) {
return getTaxonomyCode().compareToIgnoreCase( o.getTaxonomyCode() );
}
- return 0;
+ if ( ( getIdentifier() != null ) && ( o.getIdentifier() != null )
+ && !ForesterUtil.isEmpty( getIdentifier().getValue() )
+ && !ForesterUtil.isEmpty( o.getIdentifier().getValue() ) ) {
+ return getIdentifier().getValuePlusProvider().compareTo( o.getIdentifier().getValuePlusProvider() );
+ }
+ return 1;
}
public void setLineage( final List<String> lineage ) {
System.out.println( entry4.getMap() );
return false;
}
- //TODO FIXME gi...
+ //TODO FIXME gi...
//
//TODO fails:
// final SequenceDatabaseEntry entry5 = SequenceDbWsTools.obtainEntry( "M30539" );
public final class UniProtTaxonomy {
- public static final String ARCHAEA = "Archaea";
- public static final String BACTERIA = "Bacteria";
- public static final String EUKARYOTA = "Eukaryota";
- private final List<String> _lineage;
- private final String _code;
- private final String _scientific_name;
- private final String _common_name;
- private final String _synonym;
- private final String _rank;
- private final String _id;
- public final static String CELLULAR_ORGANISMS = "cellular organisms";
- public final static String VIRUSES = "Viruses";
+ public static final String ARCHAEA = "Archaea";
+ public static final String BACTERIA = "Bacteria";
+ public static final String EUKARYOTA = "Eukaryota";
+ private final List<String> _lineage;
+ private final String _code;
+ private final String _scientific_name;
+ private final String _common_name;
+ private final String _synonym;
+ private final String _rank;
+ private final String _id;
+ public final static String CELLULAR_ORGANISMS = "cellular organisms";
+ public final static String VIRUSES = "Viruses";
+ public static final String X = "x";
public UniProtTaxonomy( final String line ) {
final String[] items = line.split( "\t" );
_synonym = synonym;
_rank = rank;
_id = id;
- if ( ( _lineage != null && _lineage.isEmpty() ) || ( ( !ForesterUtil.isEmpty( _lineage ) ) && !_lineage.get( _lineage.size() - 1 ).equalsIgnoreCase( _scientific_name ) ) ) {
+ if ( ( ( _lineage != null ) && _lineage.isEmpty() )
+ || ( ( !ForesterUtil.isEmpty( _lineage ) ) && !_lineage.get( _lineage.size() - 1 )
+ .equalsIgnoreCase( _scientific_name ) ) ) {
_lineage.add( _scientific_name );
}
-
}
-
-
/**
* Creates deep copy for all fields, except lineage.
*
public String getSynonym() {
return _synonym;
}
-
+
public final static UniProtTaxonomy createSpecialFromScientificName( final String sn ) {
-
- List<String> lineage = new ArrayList<String>();
- String code = "";
- String common_name = "";
+ final List<String> lineage = new ArrayList<String>();
+ final String code = "";
+ final String common_name = "";
String scientific_name = "";
- String synonym = "";
+ final String synonym = "";
String rank = "";
String id = "";
-
if ( sn.equalsIgnoreCase( BACTERIA ) ) {
scientific_name = BACTERIA;
lineage.add( "cellular organisms" );
else if ( sn.equalsIgnoreCase( ARCHAEA ) ) {
scientific_name = ARCHAEA;
lineage.add( "cellular organisms" );
-
rank = "superkingdom";
id = "2157";
}
rank = "superkingdom";
id = "10239";
}
+ else if ( sn.equalsIgnoreCase( X ) ) {
+ scientific_name = X;
+ }
else {
throw new IllegalArgumentException( "illegal attempt to make UniProt taxonomy for :" + sn );
}
return new UniProtTaxonomy( lineage, code, common_name, scientific_name, synonym, rank, id );
-
-
}
}