@@ -1003,20 +1003,47 @@ String uniqueName() {
10031003 this .parent == null ? "(roots)" : this .parent .name );
10041004 return "?" ;
10051005 }
1006- for (Taxon other : nodes )
1007- if (other != this && other .name .equals (this .name )) {
1006+ boolean homonymp = false ;
1007+ boolean informativeFail = false ;
1008+
1009+ if (true ) {
1010+ for (Taxon other : nodes )
1011+ if (other != this && other .name .equals (this .name )) {
1012+ homonymp = true ;
1013+ Taxon i = this .informative ();
1014+ if (i != null && i .equals (other .informative ())) {
1015+ informativeFail = true ;
1016+ break ;
1017+ }
1018+ }
1019+ if (informativeFail || homonymp ) {
1020+ String urank = "" ;
1021+ if (this .rank != null ) urank = this .rank + " " ;
1022+ if (informativeFail )
1023+ urank = urank + " " + this .sourceIds .get (0 );
1024+
10081025 Taxon i = this .informative ();
1009- if ((i != other .informative () &&
1010- i != null &&
1011- !this .name .endsWith (" sp." ))) {
1012- String urank = "" ;
1013- if (this .rank != null ) urank = this .rank + " " ;
1014- String irank = "" ;
1015- if (i .rank != null ) irank = i .rank + " " ;
1016- return this .name + " (" + urank + "in " + irank + i .name + ")" ;
1017- } else
1018- return this .name + " (" + this .getSourceIdsString () + ")" ;
1019- }
1026+ String irank = "" ;
1027+ if (i .rank != null ) irank = i .rank + " " ;
1028+ return this .name + " (" + urank + "in " + irank + i .name + ")" ;
1029+ } else return "" ;
1030+ }
1031+ else
1032+ // Old buggy version, delete after above has been tested
1033+ for (Taxon other : nodes )
1034+ if (other != this && other .name .equals (this .name )) {
1035+ Taxon i = this .informative ();
1036+ if ((i != other .informative () &&
1037+ i != null &&
1038+ !this .name .endsWith (" sp." ))) {
1039+ String urank = "" ;
1040+ if (this .rank != null ) urank = this .rank + " " ;
1041+ String irank = "" ;
1042+ if (i .rank != null ) irank = i .rank + " " ;
1043+ return this .name + " (" + urank + "in " + irank + i .name + ")" ;
1044+ } else
1045+ return this .name + " (" + this .getSourceIdsString () + ")" ;
1046+ }
10201047 return "" ;
10211048 }
10221049
@@ -1101,6 +1128,20 @@ Taxon sample(int k, Taxonomy tax) {
11011128 return sam ;
11021129 }
11031130
1131+ public boolean isHidden () {
1132+ return ((this .properFlags | this .inheritedFlags ) &
1133+ (Taxonomy .HIDDEN |
1134+ Taxonomy .EXTINCT |
1135+ Taxonomy .MAJOR_RANK_CONFLICT |
1136+ Taxonomy .TATTERED |
1137+ Taxonomy .NOT_OTU |
1138+ Taxonomy .HYBRID |
1139+ Taxonomy .VIRAL |
1140+ Taxonomy .UNCLASSIFIED |
1141+ Taxonomy .ENVIRONMENTAL |
1142+ Taxonomy .INCERTAE_SEDIS )) != 0 ;
1143+ }
1144+
11041145 // ----- Methods intended for use in jython scripts -----
11051146
11061147 // Patch system commands are add, move, synonym, prune, fold, flag
@@ -1157,6 +1198,17 @@ public void hideDescendants() {
11571198 }
11581199 }
11591200
1201+ // Hide up to but not including the given rank
1202+ public void hideDescendantsToRank (String rank ) {
1203+ if (this .children != null )
1204+ for (Taxon child : this .children ) {
1205+ if (child .rank != null && !child .rank .equals (rank )) {
1206+ child .properFlags = Taxonomy .HIDDEN ;
1207+ child .hideDescendantsToRank (rank );
1208+ }
1209+ }
1210+ }
1211+
11601212 public void synonym (String name ) {
11611213 this .taxonomy .addSynonym (name , this );
11621214 }
@@ -1176,7 +1228,7 @@ public void elide() {
11761228 System .err .format ("** %s is a root\n " , this );
11771229 else {
11781230 if (this .children == null )
1179- System .err .format ("** Warning: %s has no children\n " , this );
1231+ ; // System.err.format("** Warning: %s has no children\n", this);
11801232 else
11811233 for (Taxon child : new ArrayList <Taxon >(this .children ))
11821234 child .changeParent (this .parent );
0 commit comments