-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmotif_search.py
executable file
·51 lines (41 loc) · 1.19 KB
/
motif_search.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
#!/usr/bin/env python3
#http://biopython-cn.readthedocs.io/zh_CN/latest/en/chr14.html
import subprocess
import sys
import Bio.Seq
from Bio import motifs
from Bio import SeqIO
from Bio.Seq import Seq
file1 = sys.argv[1] #fasta file
file2 = sys.argv[2] #bed file
output = subprocess.run(['fastaFromBed', '-fi', file1, '-bed', file2], stdout=subprocess.PIPE )
bytes = output.stdout
stdout=bytes.decode('utf-8')
#print(stdout)
fasta_write = open ("TAIR_fasta_output", "w")
fasta_write.write(stdout)
fasta_write.close()
#fasta_frombed = open ("TAIR_fasta_output", "r")
instances = [Seq("TACAA")]
m=motifs.create(instances)
myfile= "TAIR_fasta_output"
for line in SeqIO.parse(myfile, "fasta"):
#print(str(line.seq))
motif=Seq(str(line.seq))
for pos in m.instances.search(motif):
print(line.id, pos[0])
# test_seq=Seq(line, m.alphabet)
# #
# instances = [Seq("TACAA"), Seq("AATGC")]
#
# m = motifs.create(instances)
# r = m.reverse_complement(instances)
#
# #m.alphabet
# #IUPACUnambiguousDNA()
# #IUPAC nucleotide ambiguity codes: W is either A or T, and V is A, C, or G
# #
# test_seq=Seq("TACACTGCATTACAACCCAAGCATTA",m.alphabet)
#
# for pos,seq in m.instances.search(test_seq):
# ... print pos, seq