-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRNAfold.py
More file actions
68 lines (36 loc) · 1.66 KB
/
Copy pathRNAfold.py
File metadata and controls
68 lines (36 loc) · 1.66 KB
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
#!/usr/bin/python
#!/usr/bin/python
# coding=utf-8
#Created by Parth Patel, DBI @ University of Delaware, Newark, Delaware 19717
#Date created: 7/21/2015
##This script generates 2nd-ary structure from miRNA precursor using RNAFold and annotate (highlight the miRNA) using RNAplot from Vienna RNA package.
import sys
import os
import subprocess
def split_at(s, c, n):
words = s.split(c)
return c.join(words[:n]), c.join(words[n:])
def RNAFOLD(NAME,LONG,SHORT):
# pipe = subprocess.Popen(["perl","HPAnnotate.pl",str(LONG),str(SHORT),str(NAME)],stdout=subprocess.PIPE) # RUN PERL SCRIPT
retcode2 = subprocess.call(["perl","HPAnnotate_test.pl",str(NAME),str(LONG),str(SHORT)]) # RUN PERL SCRIPT
if __name__ == '__main__':#calls the main function
LONG_SEQ_FILE = str(sys.argv[1]) #"Aspa_mapped_genomic_seq.fa"
SHORT_SEQ_FILE = str(sys.argv[2]) #"SHORT.txt"
fl_in = open(LONG_SEQ_FILE,'r')
fs_in = open(SHORT_SEQ_FILE,'r')
lines = fs_in .readlines() #read SHORT SEQ. FILE INTO ARRAY
data = fl_in.read().split('>')
count=0 #loop counter
for i in data[1:]:
block = i.split('\n')
name = block[0].split(' ')[0]
name = split_at(name,'_',2)
#print name[0]
Long_SEQ = block[1]
# print Long_SEQ
Short_SEQ = lines[count].rstrip() #remove newline from python#fs_in.read().split('\n')[0]
# print Short_SEQ
# print name[0]
RNAFOLD(name[0].rstrip(),Long_SEQ,SHORT_SEQ_FILE)
count+=1
print "Done..\n"