File: fakeQuals.py

package info (click to toggle)
pbsuite 15.8.24%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 14,512 kB
  • ctags: 1,951
  • sloc: python: 10,962; sh: 147; xml: 21; makefile: 14
file content (28 lines) | stat: -rwxr-xr-x 884 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/python
import sys
from optparse import OptionParser
from FileHandlers import FastaFile

USAGE = """USAGE: %prog <input.fasta> <output.qual> [--options]
Creates fake quality information for fasta files that do not have associated \
quality information"""

if __name__ == '__main__':
    parser = OptionParser(USAGE)
    parser.add_option("-s", "--score", default="40", \
                      help=("Score to give every base in fasta file.\n" \
                            "DEFAULT = 40"))
    
    opts, args = parser.parse_args()
    
    if len(args) != 2:
        parser.error("Error! Expected exactly 2 arguments.")
    fastaName, outName = args
    fasta  = FastaFile(fastaName)
    fout = open(outName,'w')
    
    for entry in fasta:
        fout.write(">" + entry + "\n" + \
                  ((opts.score + " ") * len(fasta[entry])) + "\n")
    
    fout.close()