Skip to content

Commit d5f3e7a

Browse files
committed
Add logging messages
1 parent 2dbea73 commit d5f3e7a

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

pgscatalog.match/src/pgscatalog/match/cli/intersect_cli.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ def run_intersect():
1313
args = parse_args()
1414

1515
# Process & sort reference variants
16+
logger.info("Reading & sorting REFERENCE variants: {}".format(args.reference))
1617
with xopen('reference_variants.txt', 'wt') as outf:
1718
outf.write('CHR:POS:A0:A1\tID_REF\tREF_REF\tIS_INDEL\tSTRANDAMB\tIS_MA_REF\n')
1819
ref_heap = []
@@ -31,6 +32,7 @@ def run_intersect():
3132
heapq.heappush(ref_heap, ([key, v['ID'], v['REF']],[IS_INDEL, STRANDAMB, IS_MA_REF]))
3233

3334
# Output the sorted reference variants
35+
logger.info("Outputting REFERENCE variants -> reference_variants.txt")
3436
n_ref = len(ref_heap)
3537
for i in range(n_ref):
3638
popped = heapq.heappop(ref_heap)
@@ -43,6 +45,7 @@ def run_intersect():
4345
outf.write('CHR:POS:A0:A1\tID_TARGET\tREF_TARGET\tIS_MA_TARGET\tALT_FREQ\tF_MISS_DOSAGE\n')
4446
target_heap = []
4547
for path in args.target:
48+
logger.info("Reading & sorting TARGET variants: {}".format(path))
4649
pvar = read_var_general(path, chrom=None) # essential not to filter if it is target (messes up common line indexing)
4750

4851
loc_afreq = path.replace('.pvar.zst', '.afreq.gz')
@@ -68,13 +71,15 @@ def run_intersect():
6871
heapq.heappush(target_heap, ([key, v['ID'], v['REF']], [IS_MA_TARGET, ALT_FREQS[i],F_MISS_DOSAGE]))
6972

7073
# Output the sorted reference variants
74+
logger.info("Outputting TARGET variants -> target_variants.txt")
7175
n_target = len(target_heap)
7276
for i in range(n_target):
7377
popped = heapq.heappop(target_heap)
7478
outf.write('\t'.join([str(x) for x in popped[0] + popped[1]]) + '\n')
7579
del target_heap
7680

7781
# Merge matched variants on sorted files
82+
logger.info("Joining & outputting matched variants -> matched_variants.txt")
7883
n_matched = 0
7984
with open('matched_variants.txt', 'w') as csvfile:
8085
for vmatch in sorted_join_variants('reference_variants.txt', 'target_variants.txt'):
@@ -86,7 +91,8 @@ def run_intersect():
8691
writer.writerow(vmatch)
8792

8893
# Output counts
89-
with open('intersect_counts_${}.txt'.format(chrom), 'w') as outf:
94+
logger.info("Outputting variant counts -> intersect_counts_$.txt")
95+
with open('intersect_counts_{}.txt'.format(chrom), 'w') as outf:
9096
outf.write('\n'.join(map(str, [n_target, n_ref, n_matched])))
9197

9298

0 commit comments

Comments
 (0)