@@ -133,6 +133,7 @@ void report(Taxonomy source, int startroots, int startcount) {
133133 that has one.
134134 */
135135 void augment (Taxon node , Taxon sink ) {
136+ if (node .prunedp ) return ;
136137 Taxon unode = alignment .getTaxon (node );
137138
138139 if (node .children == null ) {
@@ -147,7 +148,9 @@ else if (a.value <= Answer.HECK_NO)
147148 // (weak no) or ambiguous (noinfo)
148149 // YES > NOINFO > NO > HECK_NO (sorry)
149150 acceptNew (node , "new/polysemy" );
150- }
151+ else
152+ tick ("ambiguous/redundant" );
153+ }
151154 } else {
152155 if (unode != null ) {
153156 for (Taxon child : node .children )
@@ -159,7 +162,7 @@ else if (a.value <= Answer.HECK_NO)
159162 augment (child , sink );
160163 // Examine mapped parents of the children
161164 boolean consistentp = true ;
162- Taxon commonParent = null ; // should end up being targetMrca(node)
165+ Taxon commonParent = null ;
163166 Taxon child1 = null , child2 = null ; // for inconsistency reporting
164167 int count = 0 ;
165168 for (Taxon child : node .children ) {
@@ -186,18 +189,12 @@ else if (a.value <= Answer.HECK_NO)
186189 } else if (!consistentp ) {
187190 inconsistent (node , child1 , child2 , sink );
188191 } else if (!commonParent .descendsFrom (sink )) {
189- // This is the philosophically troublesome case.
190- // Could be either an outlier/mistake, or something serious.
191- if (node .markEvent ("sibling-sink mismatch" ))
192- System .out .format ("* Parent of %s's children's images, %s, is not a descendant of %s\n " ,
193- node , commonParent , sink );
194- inconsistent (node , child1 , child2 , sink );
192+ overtake (node , commonParent , sink );
195193 } else if (refinementp (node , sink )) {
196194 Taxon newnode = acceptNew (node , "new/refinement" );
197195 takeOld (node , newnode );
198196 takeOn (node , newnode , 0 ); // augmentation
199197 } else {
200- // 'trouble' = paraphyly risk - plain merge.
201198 takeOn (node , commonParent , 0 );
202199 // should include a witness for debugging purposes - merged to/from what?
203200 reject (node , "reject/merged" , commonParent , Taxonomy .MERGED );
@@ -215,7 +212,8 @@ else if (a.value <= Answer.HECK_NO)
215212
216213 void inconsistent (Taxon node , Taxon child1 , Taxon child2 , Taxon sink ) {
217214 // Paraphyletic / conflicted.
218- // Put the new children unplaced under the mrca of the placed children.
215+ // Put the new children unplaced under the sink, or the mrca of the
216+ // placed children, whichever is smaller.
219217 reportConflict (node , child1 , child2 , sink );
220218 // Tighten it if possible... does this always make sense?
221219 Taxon unode = alignment .getTargetMrca (node );
@@ -225,6 +223,35 @@ void inconsistent(Taxon node, Taxon child1, Taxon child2, Taxon sink) {
225223 reject (node , "reject/inconsistent" , sink , Taxonomy .INCONSISTENT );
226224 }
227225
226+ private final static boolean MORE_SENSIBLE_BUT_DOESNT_WORK = false ;
227+
228+ // The symptom of getting this wrong is the creation of a cycle.
229+
230+ void overtake (Taxon node , Taxon commonParent , Taxon sink ) {
231+ // This is a troublesome case.
232+ // Workspace says children are under sink, but source says they're not.
233+ if (node .markEvent ("sibling-sink mismatch" ))
234+ System .out .format ("* Parent of %s's children's images, %s, is an ancestor of %s\n " ,
235+ node ,
236+ commonParent ,
237+ sink );
238+
239+ if (MORE_SENSIBLE_BUT_DOESNT_WORK ) {
240+ takeOn (node , commonParent , 0 );
241+ reject (node , "reject/overtaken" , commonParent , Taxonomy .MERGED );
242+ } else {
243+ // was: inconsistent(node, child1, child2, sink);
244+ Taxon point ;
245+ Taxon unode = alignment .getTargetMrca (node );
246+ if (unode != null && unode .descendsFrom (sink ))
247+ point = unode ;
248+ else
249+ point = sink ;
250+ takeOn (node , point , Taxonomy .UNPLACED );
251+ reject (node , "reject/overtaken" , point , Taxonomy .MERGED );
252+ }
253+ }
254+
228255 /* Refinement: feature necessary for merging Silva into the
229256 skeleton and NCBI into Silva. This lets an internal "new" node
230257 (in the "new" taxonomy) be inserted in between internal "old"
0 commit comments