Mercurial > repos > lijing > bubio
changeset 4:7f94bf630447 draft
interleave
author | lijing |
---|---|
date | Thu, 02 Nov 2017 12:37:35 -0400 |
parents | 85a6e3a77554 |
children | 7c679db88fa3 |
files | home/lijing/galaxy/tools/ngs_mapping/interleave-fastqgz-MITOBIM.py interleave.xml |
diffstat | 2 files changed, 77 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/home/lijing/galaxy/tools/ngs_mapping/interleave-fastqgz-MITOBIM.py Thu Nov 02 12:37:35 2017 -0400 @@ -0,0 +1,45 @@ +#!/usr/bin/python +# encoding:utf8 +# authors: Erik Garrison, Sébastien Boisvert +# modified by github@cypridina on 20151104 to work with MITObim +"""This script takes two fastq or fastq.gz files and interleaves them +Usage: + interleave-fasta fasta_file1 fasta_file2 +""" + +import sys,re + +def interleave(f1, f2): + """Interleaves two (open) fastq files. + """ + while True: + line = f1.readline() + if line.strip() == "": + break + print re.sub(r" 1:N.*", "/1",line.strip()) + + for i in xrange(3): + print re.sub(r" 2:N.*","/2",f1.readline().strip()) + + for i in xrange(4): + print re.sub(r" 2:N.*","/2",f2.readline().strip()) + +if __name__ == '__main__': + try: + file1 = sys.argv[1] + file2 = sys.argv[2] + except: + print __doc__ + sys.exit(1) + + if file1[-2:] == "gz": + import gzip + with gzip.open(file1) as f1: + with gzip.open(file2) as f2: + interleave(f1, f2) + else: + with open(file1) as f1: + with open(file2) as f2: + interleave(f1, f2) + f1.close() + f2.close()
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/interleave.xml Thu Nov 02 12:37:35 2017 -0400 @@ -0,0 +1,32 @@ +<tool id="interleave" name="interleave fastqs" version="0.1.0"> + <description>takes two fastq or fastq.gz files and interleaves them</description> + <requirements> + <requirement type="package" version="4.0.2">mira4_assembler</requirement> + </requirements> + <stdio> + <exit_code range="1:" /> + </stdio> + <command><![CDATA[ + /home/lijing/galaxy/tools/ngs_mapping/interleave-fastqgz-MITOBIM.py + $fastq1 $fastq2 > $output1 + ]]></command> + <inputs> + <param type="data" name="fastq1" format="fastqsanger,fastq" + label="Paire end forward read" /> + <param type="data" name="fastq2" format="fastqsanger,fastq" + label="Paire end reverse read" /> + </inputs> + <outputs> + <data name="output1" format="fastqsanger" /> + </outputs> + + <help><![CDATA[ + +This script takes two fastq or fastq.gz files and interleaves them + +Usage: + interleave-fastqgz-MITOBIM.py fastq1 fastq2 > out.fastq + + ]]></help> + +</tool>