Skip to content

Commit 7e19c62

Browse files
authored
Merge pull request #563 from nf-core/nuc_cont_parsing_fix
Bugfix. Corrected number of relevant SNPs and NAs in `print_x_contamination.py`.
2 parents cf7d057 + a7c0478 commit 7e19c62

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
5757
* Nuclear contamination is now reported with the correct library names.
5858
* Merged all tutorials and FAQs into `usage.md` for display on nf-co.re
5959
* Corrected header of nuclear contamination table (`nuclear_contamination.txt`).
60+
* Fixed a bug with `nSNPs` definition in `print_x_contamination.py`. Number of SNPs now correctly reported.
61+
* `print_x_contamination.py` now correctly converts all NA values to "N/A".
6062

6163
### `Dependencies`
6264

bin/print_x_contamination.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77

88
## Function to convert a set of elements into floating point numbers, when possible, else leave them be.
99
def make_float(x):
10-
print (x)
10+
# print (x)
1111
output=[None for i in range(len(x))]
1212
## If value for an estimate/error is -nan, replace with "NA". JSON does not accept NaN as a valid field.
1313
for i in range(len(x)):
14-
if x[i] == "-nan":
14+
if x[i] == "-nan" or x[i] == "nan":
1515
output[i]="N/A"
1616
continue
1717
try:
@@ -32,13 +32,14 @@ def make_float(x):
3232
ml1, err_ml1="N/A","N/A"
3333
mom2, err_mom2= "N/A","N/A"
3434
ml2, err_ml2="N/A","N/A"
35+
nSNPs="0"
3536
with open(fn, 'r') as f:
3637
Estimates={}
3738
Ind=re.sub('\.X.contamination.out$', '', fn).split("/")[-1]
3839
for line in f:
3940
fields=line.strip().split()
40-
if line.strip()[0:21] == "[readicnts] Has read:":
41-
nSNPs=fields[4]
41+
if line.strip()[0:19] == "We have nSNP sites:":
42+
nSNPs=fields[4].rstrip(",")
4243
elif line.strip()[0:7] == "Method1" and line.strip()[9:16] == 'new_llh':
4344
mom1=fields[3].split(":")[1]
4445
err_mom1=fields[4].split(":")[1]

0 commit comments

Comments
 (0)