# HG changeset patch # User davidvanzessen # Date 1404726560 14400 # Node ID 8e3d95d7f342a4c429f8cea630b8b361c0a964d2 # Parent 79be0752711d9b094f972f65adca6286329acfe5 Uploaded diff -r 79be0752711d -r 8e3d95d7f342 demultiplex.xml --- a/demultiplex.xml Tue Jul 01 08:27:57 2014 -0400 +++ b/demultiplex.xml Mon Jul 07 05:49:20 2014 -0400 @@ -16,156 +16,307 @@ + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 79be0752711d -r 8e3d95d7f342 r_wrapper.sh --- a/r_wrapper.sh Tue Jul 01 08:27:57 2014 -0400 +++ b/r_wrapper.sh Mon Jul 07 05:49:20 2014 -0400 @@ -38,4 +38,4 @@ python $dir/trim.py --input $file.fasta --output ${file}_trimmed.fasta --start $trim_start --end $trim_end echo "$barcode$count$file.fastq$file.fasta${file}_trimmed.fasta" >> $output done < output.txt -echo "Original fasta after trim" >> $output +echo "" >> $output diff -r 79be0752711d -r 8e3d95d7f342 tool_dependencies.xml --- a/tool_dependencies.xml Tue Jul 01 08:27:57 2014 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,6 +0,0 @@ - - - - - - diff -r 79be0752711d -r 8e3d95d7f342 trim.py --- a/trim.py Tue Jul 01 08:27:57 2014 -0400 +++ b/trim.py Mon Jul 07 05:49:20 2014 -0400 @@ -2,8 +2,8 @@ #docs.python.org/dev/library/argparse.html parser = argparse.ArgumentParser() -parser.add_argument("--input", help="Input folder with files") -parser.add_argument("--output", help="Output file") +parser.add_argument("--input", help="Input fasta") +parser.add_argument("--output", help="Output fasta") parser.add_argument("--start", help="How many nucleotides to trim from the start", type=int) parser.add_argument("--end", help="How many nucleotides to trim from the end", type=int) @@ -11,25 +11,44 @@ start = int(args.start) end = int(args.end) -if end <= 0: +if end <= 0 and start <= 0: import shutil shutil.copy(args.input, args.output) import sys sys.exit() + + currentSeq = "" currentId = "" -with open(args.input, 'r') as i: - with open(args.output, 'w') as o: - for line in i.readlines(): - if line[0] is ">": - if currentSeq is not "" or currentId is not "": - o.write(currentId) - o.write(currentSeq[start:-end] + "\n") - currentId = line - currentSeq = "" - else: - currentSeq += line.rstrip() - o.write(currentId) - o.write(currentSeq.rstrip()[start:-end] + "\n") +if end is 0: + with open(args.input, 'r') as i: + with open(args.output, 'w') as o: + for line in i.readlines(): + if line[0] is ">": + currentSeq = currentSeq[start:] + if currentSeq is not "" and currentId is not "": + o.write(currentId) + o.write(currentSeq + "\n") + currentId = line + currentSeq = "" + else: + currentSeq += line.rstrip() + o.write(currentId) + o.write(currentSeq[start:] + "\n") +else: + with open(args.input, 'r') as i: + with open(args.output, 'w') as o: + for line in i.readlines(): + if line[0] is ">": + currentSeq = currentSeq[start:-end] + if currentSeq is not "" and currentId is not "": + o.write(currentId) + o.write(currentSeq + "\n") + currentId = line + currentSeq = "" + else: + currentSeq += line.rstrip() + o.write(currentId) + o.write(currentSeq[start:-end] + "\n")