Mercurial > repos > jowong > prince_galaxy
diff prince_postprocess.py @ 8:63f3743c2ae4 draft
planemo upload
author | jowong |
---|---|
date | Tue, 13 Nov 2018 12:19:53 -0500 |
parents | 82569b47df8d |
children | 5b816b501285 |
line wrap: on
line diff
--- a/prince_postprocess.py Mon Oct 29 08:30:06 2018 -0400 +++ b/prince_postprocess.py Tue Nov 13 12:19:53 2018 -0500 @@ -8,8 +8,8 @@ input = parser.add_argument_group('Input', '') input.add_argument('-i', '--input', nargs=1, required=True, help="PRINCE OUTPUT") -input.add_argument('-s', '--sample', nargs='*', required=True, help="Sample names") - +input.add_argument('-s', '--sample', nargs='+', required=True, help="Sample names") +input.add_argument('-f', '--file', nargs='+', required=True, help="File of forward reads in galaxy convention") if len(sys.argv) == 0: parser.print_usage() sys.exit(1) @@ -18,6 +18,19 @@ #print(args.input) #sample_name = re.sub('(_1.fastq(.gz)*|_2.fastq(.gz)*|.fastq(.gz)*)', '', args.label.rstrip().lstrip()) +sample_dict={} +path_index = 0 +for path in args.file: + with open(path) as f: + for line in f: + sample_dict[re.sub(".*/","",line)] = sample[path_index] + path_index += 1 + + + + + + with open(args.input[0]) as prince_output: with open('prince_postprocess_output.txt', 'w') as output: @@ -25,8 +38,9 @@ index = 0 for line in prince_output: if x%2 == 0: - sample = re.sub('(_1.fastq(.gz)*|_2.fastq(.gz)*|.fastq(.gz)*)', '', args.sample[index]) - output.write(re.sub('.*.dat', sample, line)) + entries =line.rstrip().split(',') + sample = re.sub('(_1.fastq(.gz)*|_2.fastq(.gz)*|.fastq(.gz)*)', '', sample_dict[entries[0]]) + output.write(re.sub(entries[0], sample, line)) index += 1 else: output.write(line)