-
Notifications
You must be signed in to change notification settings - Fork 0
/
mol_weights_seqs.py
74 lines (52 loc) · 1.75 KB
/
mol_weights_seqs.py
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''====
Program must have a file to run!
===='''
import os
from argparse import ArgumentParser, FileType
from collections import Counter
import sys
#from sys import stdin, stdout, stderr
def print_weights(file):
reads = []
#with open(file, 'r') as f:
for line in file:
reads.append(line.strip())
for read in reads:
nucleotide_dict = Counter(read)
print(round(nucleotide_dict['A'] * 313.21 + \
nucleotide_dict['C'] * 289.18 + \
nucleotide_dict['G'] * 329.21 + \
nucleotide_dict['T'] * 304.2 - 61.96, 1))
def codon_window(text, k = int(3)):
for i in range(len(text) - k + 1):
yield text[i:i+k]
if __name__ == '__main__':
parser = ArgumentParser(
description = 'get weights from DNA sequence')
parser.add_argument('-r','--read-file',
nargs='?',
dest='read_file',
type=FileType('r'),
help='input READS file')
'''parser.add_argument('-f', '--file',
nargs='?',
type=FileType('r'),
help='input READS file',
required=True)
'''
args = parser.parse_args()
if not args.read_file:
print('\n\n')
parser.print_help()
print(__doc__, file=sys.stderr)
sys.exit(0)
print_weights(args.read_file)
#codon_dict = Counter([codon for codon in codon_window(text)])
#print(codon_dict['TAG'], codon_dict['TAA'], codon_dict['TGA'])
fin = open('seq.txt', 'r')
reads=[]
for line in fin.readlines():
reads.append(line.replace('\n',''))
fout=open('output7.txt', 'w')