Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
try except clause to pick up error
  • Loading branch information
proost committed Oct 27, 2017
1 parent 8088d1b commit de5f0ff
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions pipeline/transcriptome.py
Expand Up @@ -2,6 +2,7 @@
import os
import sys
import shutil
import re

from cluster import wait_for_job
from utils.matrix import read_matrix, write_matrix, normalize_matrix_counts, normalize_matrix_length
Expand Down Expand Up @@ -500,15 +501,12 @@ def htseq_to_matrix(self):
full_path = os.path.join(htseq_output, file)
with open(full_path, "r") as f:
for row in f:
try:
gene_id, count = row.strip().split('\t')
except Exception as e:
print("Error parsing file %s. Error in line %s" % (file, row), file=sys.stderr)
finally:
if gene_id not in counts.keys():
counts[gene_id] = {}

counts[gene_id][file] = count
gene_id, count = re.split('\t+', row.strip())

if gene_id not in counts.keys():
counts[gene_id] = {}

counts[gene_id][file] = count

output_file = self.dp[g]['exp_matrix_output']
os.makedirs(os.path.dirname(output_file), exist_ok=True)
Expand Down

0 comments on commit de5f0ff

Please sign in to comment.