From 69528664b9fa0fb693d2de7482a90bee0aa42a0f Mon Sep 17 00:00:00 2001 From: Tom Clegg Date: Thu, 13 Oct 2022 10:47:02 -0400 Subject: [PATCH] 19524: Read multiple phenotype files. Arvados-DCO-1.1-Signed-off-by: Tom Clegg --- plot.py | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/plot.py b/plot.py index eadcd4cab7..886e8cc691 100644 --- a/plot.py +++ b/plot.py @@ -20,15 +20,20 @@ if sys.argv[2]: sampleid = row[1] samples.append(sampleid) phenotype_column = int(sys.argv[4]) - with open(sys.argv[3], 'rt', newline='') as phenotype: - dialect = csv.Sniffer().sniff(phenotype.read(1024)) - phenotype.seek(0) - for row in csv.reader(phenotype, dialect): - tag = row[0] - label = row[phenotype_column] - for sampleid in samples: - if tag in sampleid: - labels[sampleid] = label + if os.path.isdir(sys.argv[3]): + phenotype_files = os.scandir(sys.argv[3]) + else: + phenotype_files = [sys.argv[3]] + for phenotype_file in phenotype_files: + with open(phenotype_file, 'rt', newline='') as phenotype: + dialect = csv.Sniffer().sniff(phenotype.read(1024)) + phenotype.seek(0) + for row in csv.reader(phenotype, dialect): + tag = row[0] + label = row[phenotype_column] + for sampleid in samples: + if tag in sampleid: + labels[sampleid] = label colors = [] labelcolors = { 'PUR': 'firebrick', -- 2.39.5