Skip to content

Commit

Permalink
Write merges to stderr for assign query
Browse files Browse the repository at this point in the history
  • Loading branch information
johnlees committed Aug 7, 2018
1 parent 30346a9 commit d826f94
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion PopPUNK/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ def printClusters(G, outPrefix, oldClusterFile = None, printRef = True):

# Ensure consistency with previous labelling
if oldClusterFile != None:
merge = False
cls_id = None

# Samples in this cluster that are not queries
Expand All @@ -323,16 +324,22 @@ def printClusters(G, outPrefix, oldClusterFile = None, printRef = True):
if len(join) > 0:
# Query has merged clusters
if len(join) < len(ref_only):
merge = True
if cls_id == None:
cls_id = oldClusterName
else:
cls_id += "_" + oldClusterName
# Exact match -> same name as before
elif len(join) == len(ref_only):
assert cls_id == None # should not have already been part of a merge
assert merge == False # should not have already been part of a merge
cls_id = oldClusterName
break

# Report merges
if merge:
merged_ids = cls_id.split("_")
sys.stderr.write("Clusters " + ",".join(merged_ids) + " have merged into " + cls_id + "\n")

# Otherwise just number sequentially starting from 1
else:
cls_id = newClsIdx + 1
Expand Down

0 comments on commit d826f94

Please sign in to comment.