Exemplo n.º 1
0
from mungo.fasta import FastaFile

from optparse import OptionParser
usage = "%prog <Input file1> <Output file>"
parser = OptionParser(usage=usage, version="%prog - Version 1")
parser.add_option('-i', '--stdin', dest='stdin', action='store_true', help='Input from stdin')
parser.add_option('-o', '--stdout', dest='stdout', action='store_true', help='Output to stdout')
options, args = parser.parse_args()
if len(args)==0:
    parser.print_help()
    sys.exit()

if options.stdin:
    f = FastaFile(sys.stdin)
else:
    f = FastaFile(args[0])

if options.stdout:
    w = FastaFile(sys.stdout, 'w')
else:
    w = FastaFile(args[1], 'w')

accList= []
for h,s in f:
    acc = h.split()[0]
    if not acc in accList:
        w.write(h,s)
        accList.append(acc)
w.close()
f.close()
Exemplo n.º 2
0
                  action='store_true',
                  help='Input from stdin')
parser.add_option('-o',
                  '--stdout',
                  dest='stdout',
                  action='store_true',
                  help='Output to stdout')
options, args = parser.parse_args()
if len(args) == 0:
    parser.print_help()
    sys.exit()

if options.stdin:
    f = FastaFile(sys.stdin)
else:
    f = FastaFile(args[0])

if options.stdout:
    w = FastaFile(sys.stdout, 'w')
else:
    w = FastaFile(args[1], 'w')

accList = []
for h, s in f:
    acc = h.split()[0]
    if not acc in accList:
        w.write(h, s)
        accList.append(acc)
w.close()
f.close()
Exemplo n.º 3
0
#!/usr/bin/env python

"""
exciseRepeats.py

Author: Tony Papenfuss
Date: Fri Mar 21 13:25:51 EST 2008

"""

import os, sys, re
from mungo.fasta import FastaFile


iFilename = sys.argv[1]
oFilename = iFilename + '.excised'

# Cleaned & now masked reads
fi = FastaFile(iFilename)
fo = FastaFile(oFilename, 'w')
for h,s in fi:
    s = s.replace('N', '')
    fo.write(h,s)
fi.close()
fo.close()
Exemplo n.º 4
0
fasta_block_split.py <iFilenames> <oFilename>

Author: Tony Papenfuss
Date: Fri Mar 30 12:58:58 EST 2007

"""

import os, sys
from mungo.fasta import FastaFile

from optparse import OptionParser
usage = "%prog [-b <block_size>] <input_file1> [<input_file2> ...] <output_file>"
parser = OptionParser(usage=usage, version="%prog - Version 1")
parser.add_option("-b", "--blocksize", action="store", type="int", 
    dest="blocksize", default="10000000")

options, args = parser.parse_args()
if len(args)==0:
    parser.print_help()
    sys.exit()


iFilenames = args[:-1]
oFilename = args[-1]

writer = FastaFile(oFilename, 'w', blockSize=10000000)
for iFilename in iFilenames:
    for h,s in FastaFile(iFilename):
        writer.write(h,s)
writer.close()
Exemplo n.º 5
0
#!/usr/bin/env python

"""
fasta_truncate.py

Author: Tony Papenfuss
Date: July 2013

"""

import sys
import argparse
from mungo.fasta import FastaFile


usage = "%prog <length> <Input file> <Output file>"

parser = argparse.ArgumentParser(description='Truncate fasta files')
parser.add_argument('length', type=int, help='Truncate to length')
parser.add_argument('input_filename', type=str, help='Input filename')
parser.add_argument('output_filename', type=str, help='Output filename')
args = parser.parse_args()

w = FastaFile(args.output_filename, 'w')
for h,s in FastaFile(args.input_filename):
    w.write(h, s[0:args.length])
w.close()
Exemplo n.º 6
0
#!/usr/bin/env python
"""
fasta_truncate.py

Author: Tony Papenfuss
Date: July 2013

"""

import sys
import argparse
from mungo.fasta import FastaFile

usage = "%prog <length> <Input file> <Output file>"

parser = argparse.ArgumentParser(description='Truncate fasta files')
parser.add_argument('length', type=int, help='Truncate to length')
parser.add_argument('input_filename', type=str, help='Input filename')
parser.add_argument('output_filename', type=str, help='Output filename')
args = parser.parse_args()

w = FastaFile(args.output_filename, 'w')
for h, s in FastaFile(args.input_filename):
    w.write(h, s[0:args.length])
w.close()
Exemplo n.º 7
0
#!/usr/bin/env python

"""
exciseRepeats.py

Author: Tony Papenfuss
Date: Fri Mar 21 13:25:51 EST 2008

"""

import os, sys, re
from mungo.fasta import FastaFile


iFilename = sys.argv[1]
oFilename = iFilename + ".excised"

# Cleaned & now masked reads
fi = FastaFile(iFilename)
fo = FastaFile(oFilename, "w")
for h, s in fi:
    s = s.replace("N", "")
    fo.write(h, s)
fi.close()
fo.close()