-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDNA-searcher.pl
executable file
·130 lines (115 loc) · 3.74 KB
/
DNA-searcher.pl
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#!/usr/bin/perl
use strict;
use warnings;
####################################################
## Daniel Pass | github.com/passdan | August 2016 ##
####################################################
# Print to the screen slower for effect!
$| = 1;
my %sequenceDB;
# Load Database
print "Which Database to load:\n- GuessWho\n- Mars\n---\n";
my $dbchoice = <STDIN>;
chomp($dbchoice);
exit 0 if ($dbchoice eq ""); # If empty string, exit.
if(lc $dbchoice eq lc "GuessWho"){
print "Loading Guess Who database!\n";sleep(1);
loadGuessWhoDB();
}elsif(lc $dbchoice eq lc "Mars"){
print "Loading Mars database!\n";sleep(1);
loadMarsDB();
}else{
print "I didn't understand that choice, exiting\n";
exit 0
}
print "Gene options are:\n";
foreach my $key (sort { $sequenceDB{$a} cmp $sequenceDB{$b} } keys %sequenceDB){
print "$key\t$sequenceDB{$key}\n";
select(undef, undef, undef, 0.1);
}
sleep(2);
my $prompt = "
############################################################
## Type a DNA sequence to search for what gene it is from ##
############################################################
Input: ";
system("clear");
print $prompt;
while (my $seq = <STDIN>){
chomp($seq);
if (exists $sequenceDB{$seq}){
my $n = 0;
print "Searching: 0%"; sleep(1);
while ($n < 100){ $n+=25; print "----$n%";sleep(1);};
my $genestring = $sequenceDB{$seq};
# Guess Who return line
if (lc $dbchoice eq lc "GuessWho"){
print "\n\nThis DNA sequence is found in the gene for: "; sleep(1);
# Mars return line
}elsif(lc $dbchoice eq lc "Mars"){
print "\n\nThis DNA sequence is most similar to : "; sleep(1);
}
foreach (split //, $genestring){
print;
select(undef, undef, undef, 0.1);
}
print "!\n";
sleep(1);
restart();
}else{
sleep(1);
print "\nOops! This sequence doesn't exist, make sure it's right!\n";
sleep(1);
restart();
}
}
sub restart {
print "\n~~~Press Enter to search again~~~\n";
while (my $in = <STDIN>){
if($in eq "\n"){
system("clear");
print $prompt;
return;
}
}
}
sub loadGuessWhoDB {
%sequenceDB = (
TAGTGGAGCATC => "Attached Earlobes", #Ears
CGGAATAACATG => "Detached Earlobes", #Ears
CCAGTGGATGGC => "Brown Eyes", #Eyes
AGTCCAGTGGTA => "Blue Eyes", #Eyes
CAGCGGTTGCTA => "Green Eyes", #Eyes
GGGACATTCCTG => "Curly Hair", #Hair Type
TTAGCCGCAACG => "Straight Hair", #Hair Type
TATGTTGAAGGC => "Blonde Hair", #Hair Colour
AACTCCCGGATA => "Brown Hair", #Hair Colour
TGATAGACTGGC => "Black Hair", #Hair Colour
CCACTGGATCTA => "Ginger Hair", #Hair Colour
GTGATGCCGTGG => "Boy", #Sex
AATACACCCGTG => "Girl", #Sex
GAGTAACGCATC => "Doesn't need glasses", #Eyesight
GTCTCCGATATG => "Needs glasses" #Eyesight
);
return;
}
sub loadMarsDB {
%sequenceDB = (
TAGTGGAGCATC => "", #Ears
CGGAATAACATG => "Unknown Species!", #Ears
CCAGTGGATGGC => "Methanosarcina barkeri", #Eyes
AGTCCAGTGGTA => "Yersinia pestis", #Eyes
CAGCGGTTGCTA => "Ulva intestinalis", #Eyes
GGGACATTCCTG => "", #Hair Type
TTAGCCGCAACG => "Homo Sapien", #Hair Type
TATGTTGAAGGC => "Bradyrhizobium japonicum", #Hair Colour
AACTCCCGGATA => "Cyanobacteria", #Hair Colour
TGATAGACTGGC => "Campylobacter jejuni", #Hair Colour
CCACTGGATCTA => "Salmonela enterica", #Hair Colour
GTGATGCCGTGG => "", #Sex
AATACACCCGTG => "Agaricus bisporus", #Sex
GAGTAACGCATC => "Influenza", #Eyesight
ATCGTTGGCGAC => "Homo sapien" #Eyesight
);
return;
}