Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix issue #11 - specify vm polarity column; handle dm empty upper left hand cell #12

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions vkmz/read.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,13 +230,17 @@ def xcmsTabular(sample_file, variable_file, matrix_file):
polarity = {}
with open(sample_file, "r") as f:
sample_data = csv.reader(f, delimiter="\t")
next(sample_data) # skip header
header = next(sample_data) # skip header
if 'polarity' in header:
polarity_index = header.index("polarity")
else:
polarity_index = 2
for row in sample_data:
sample = row[0]
if POLARITY:
polarity[sample] = POLARITY
else:
polarity[sample] = polaritySanitizer(row[2])
polarity[sample] = polaritySanitizer(row[polarity_index])
except IOError:
print(f"Error while reading the XCMS tabular file {sample_file}")
raise
Expand Down Expand Up @@ -285,6 +289,9 @@ def xcmsTabular(sample_file, variable_file, matrix_file):
with open(matrix_file, "r") as f:
matrix_data = csv.reader(f, delimiter="\t")
header = next(matrix_data) # list of samples
if header[0] == "":
header[0] = "X"
i = 0
# remove empty columns
# required for W4M-XCMS 1.7
# TODO: check W4M-XCMS 3.0
Expand Down