-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTargets.py
44 lines (44 loc) · 1.76 KB
/
Targets.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
def Targets ( DNA ) :
# Opening the .log file in append mode, since it already contains previous results.
filename = input ( "Save target-finding results to file: ") + ".log"
with open ( filename, "a" ) as fileseq :
Count = 0
Targets = []
print ( "Press Enter to skip introducing more targets.\n" )
while True:
trgt = input ( "Search for a specific target: ")
if len ( trgt ) < 1:
break
else:
Targets.append ( trgt )
continue
for Target in Targets:
fileseq.write ( "Targets found for " + Target + ":\n")
print ( 'Targets found for', Target, ':' )
Ind = 0
Hits = 0
for Nucl in DNA :
if Nucl == list ( Target ) [ Count ] :
Count += 1
Ind += 1
else:
Count -= Count
Ind += 1
if Count == len ( list ( Target ) ) :
Count -= Count
Hits += 1
print (
Ind - len ( list ( Target ) ) + 1, '-',
''.join ( Target ), '-', Ind
)
fileseq.write (
str ( Ind - len ( list ( Target ) ) + 1 ) + ' - ' +
''.join ( Target ) + ' - ' + str ( Ind ) + "\n"
)
fileseq.write (
str ( Hits ) + " " +
''.join ( Target ) + " targets found.\n"
)
fileseq.write( "-------------\n" )
print( Hits,''.join ( Target ), ' targets found.' )
print( '--------------' )