duocore | #1 Posté le 5/9/2013 à 08:28:57 |
---|
| bonjour,
j'ai créé un logiciel CATG: il s'agit d'un logiciel qui permet a partir d'une sequence ADN:
CATG is software that allows for starting from a DNA sequence: -Complementation (ATCG -> TAGC) -Reverse (ATCG -> GCTA) -Or 2 (ATCG -> CGAT)
j'ai voulu rajouter une fonction de recherche de palindrome:
sequence qui se lit dans les 2 sens comme LEVEL, GAG,LAVAL mais ici il n'y aura comme lettre que soit A,C,T,G
voici le pseudo code de la fonction:
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
| adn1.text a=1 b=2 adn2.text="" debut FOR I = a TO b BASE1 = Mid$(Upper$(ADN1.Text), I, 1) IF BASE1 = "A" THEN BASE2 = "T" ELSE IF BASE1 = "T" THEN BASE2 = "A" ELSE IF BASE1 = "G" THEN BASE2 = "C" ELSE IF BASE1 = "C" THEN BASE2 = "G" ENDIF ADN2.Text = BASE2 & ADN2.Text NEXT
si adn1.text=adn2.text alors
b=b++ GOTO debut sinon enregistre dans fichier
a=b+1 b=a+1 GOTO debut fin
|
et voici le code source complet du logiciel:
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
| PUBLIC SUB Val_Click() DIM I AS INTEGER, D AS INTEGER, F AS INTEGER DIM LADN1 AS INTEGER DIM BASE1 AS STRING DIM BASE2 AS STRING D = 1 F = 2
LADN1 = Len(ADN1.Text) IF (Comp.value = FALSE AND Rev.Value = FALSE) AND Pal.Value = FALSE THEN Message.Warning("Vous avez oublier de cocher une ou les 3 cases") ELSE IF Comp.Value = TRUE AND Rev.Value = TRUE THEN FOR I = 1 TO LADN1 BASE1 = Mid$(Upper$(ADN1.Text), I, 1) IF BASE1 = "A" THEN BASE2 = "T" ELSE IF BASE1 = "T" THEN BASE2 = "A" ELSE IF BASE1 = "G" THEN BASE2 = "C" ELSE IF BASE1 = "C" THEN BASE2 = "G" ENDIF ADN2.Text = BASE2 & ADN2.Text NEXT
ELSE IF Comp.Value = TRUE THEN FOR I = 1 TO LADN1 BASE1 = Mid$(Upper$(ADN1.Text), I, 1) IF BASE1 = "A" THEN BASE2 = "T" ELSE IF BASE1 = "T" THEN BASE2 = "A" ELSE IF BASE1 = "G" THEN BASE2 = "C" ELSE IF BASE1 = "C" THEN BASE2 = "G" ENDIF ADN2.Text = ADN2.Text & BASE2 NEXT
ELSE IF Rev.Value = TRUE THEN FOR I = 1 TO LADN1 BASE1 = Mid$(Upper$(ADN1.Text), I, 1) BASE2 = BASE1 ADN2.Text = BASE2 & ADN2.Text NEXT
ENDIF IF Pal.Value = TRUE THEN ' inserer ici le code pour la recherche de palindrome start: FOR I = D TO F BASE1 = Mid$(Upper$(ADN1.Text), I, 1) IF BASE1 = "A" THEN BASE2 = "T" ELSE IF BASE1 = "T" THEN BASE2 = "A" ELSE IF BASE1 = "G" THEN BASE2 = "C" ELSE IF BASE1 = "C" THEN BASE2 = "G" ENDIF ADN2.Text = BASE2 & ADN2.Text PalT.Text = PalT.Text & BASE1 NEXT
IF PalT.Text = ADN2.Text THEN F = F + 1 'la ligne print permet de servir de debug PRINT PalT.text, ADN2.Text GOTO start ELSE 'la ligne print permet de servir de debug PRINT I, D, F, ADN2.Text, I, PalT.Text PalT.Text = PalT.Text & Chr$(10) D = F + 1 F = F + 1 IF I = LADN1 + 1 THEN GOTO fini ELSE GOTO start
ENDIF ENDIF ENDIF fini: END PUBLIC SUB mnuAbout_Click()
Licence.ShowModal
END
|
et voici mon fichier FMain.form
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
| # Gambas Form File 2.0
Form Form Move(0,0,672,532) #(Scaled) = FALSE Text = ("CATG ver. 0.0.1") Border = Window.Fixed mnuAide Menu Text = ("Aide") mnuAbout Menu Text = ("A propos de ...") } } Seq1 Frame Move(14,35,644,133) Text = ("Sequence ADN 1") ADN1 TextArea Move(14,21,616,98) Text = ("") } } Comp CheckBox Move(28,182,140,14) Text = ("Complementation") } Rev CheckBox Move(175,182,84,14) Text = ("Inversion") } Pal CheckBox Move(266,182,91,14) Text = ("Palimdrom") } Val ToggleButton Move(511,182,133,14) Text = ("Validation") } Seq2 Frame Move(14,210,644,133) Text = ("Sequence ADN 2") ADN2 TextArea Move(14,21,616,98) Text = ("") } } PalT TextArea Move(28,350,616,147) Text = ("") } }
|
voici mon probleme:
par exemple j'ai la sequence initiale ADN1.Text: TA
ADN2.Text me retourne ceci: TTATA et palT.Text ceci: TATA alors que les 3 *.Text devraient me retourner TA
et avec un autre exemple j'ai ceci ADN1.Text:CATGCTATA ADN2.Text:TTATAGCATG PalT.Text:CA T G C T A T A
cela devrais donner ADN1.Text:CATGCTATA ADN2.Text:TATAGCATG PalT.Text:CATG 'et sur une autre ligne TATA
comment y remedier
merci de votre aide |
duocore | #2 Posté le 5/9/2013 à 22:24:45 |
---|
| voici un code en php que j'ai trouvé:
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
| <!-- Title: Find Palindrome Script Author: Joseba Bikandi License: GNU GLP v2 -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Palindromic sequences finder</title> </head> <body bgcolor="#ffffff"> <h1>Palindromic sequences finder<br> </h1> <form method="post" action="<? print $_SERVER["PHP_SELF"]; ?>"> <textarea name="seq" cols="75" rows="10">AACAATGCCATGATGATGATTATTACGACACAACAACACCGCGCTTGACGGCGGCGGATGGATGCCG CGATCAGACGTTCAACGCCCACGTAACGTAACGCAACGTAACCTAACGACACTGTTAACGGTACGAT </textarea> <br> Minimum length OF palindromic sequence: <select name="min"> <option>4</option> <option>5</option> <option>6</option> <option>7</option> <option>8</option> <option>9</option> <option>10</option> </select> <br> Maximum length OF palindromic sequence: <select name="max">
<option>5</option> <option>6</option> <option>7</option> <option>8</option> <option>9</option> <option selected="selected">10</option> <option>11</option> <option>12</option> <option>13</option> <option>14</option> <option>15</option> <option>16</option> <option>17</option> <option>18</option> <option>19</option> <option>20</option> </select> <br> <input value="Find Palindromic sequences" type="submit"></form> <p> </p> <hr><font size="+1"><b><u>Definitions</u></b></font> <br> <b>Palindromic sequence</b>: <br> <!-- #BeginEditable "Definition" --> A DNA sequence whose 5'-to-3' sequence IS identical ON EACH DNA strand. The sequence IS the same when one strand IS READ left TO right AND the other strand IS READ right TO left. Recognition sites OF many restriction enzymes are palindromic. <hr> Source code (PHP) IS available <a href=http://www.biophp.org/minitools/find_palindromes>here</a> </body> </html>
<PRINTphp error_reporting(1);
$seq=remove_useless_from_DNA($_POST["seq"]); If($seq=="")"No sequence available");}
$min=$_POST["min"]; $max=$_POST["max"];
$thearray=find_palindromic_seqs ($seq,$min,$max);
// PRINT ARRAY PRINT "Palindromic sequences with length $min to $max within string";
PRINT "<table border=1 cellpadding=5><tr><td bgcolor=AAAAFF>Position</td><td bgcolor=AAAAFF>Sequence</td></tr>\n"; foreach ($thearray AS $key => $val) PRINT "<tr><td>$key</td><td>$val</td></tr>"; } PRINT "</table>\n";
//print_r($thearray);
// Description FOR find_palindromic_seqs // Searches sequence FOR palindromic substrings // // Parameters // $seq IS the sequence TO be searched // $min the minimum length OF palindromic sequence TO be searched // $max the maximum length OF palindromic sequence TO be searched // // Return // An array: keys are positions IN genome, AND values are length OF palindromic sequences // // Requeriments: // DNA_is_palindrome FUNCTION find_palindromic_seqs ($seq,$min,$max) $result=""; $seq_len=strlen($seq); for($i=0;$i<$seq_len-$min+1;$i++) $j=$min; while($j<$max+1 AND ($i+$j)<=$seq_len) $sub_seq=substr($seq,$i,$j); IF (DNA_is_palindrome($sub_seq)==1) $results [$i]=$sub_seq; } $j++; }
} RETURN $results; }
// Description FOR DNA_is_palindrome // Checks whether a DNA sequeence IS palindromic. // When degenerate nucleotides are included IN the sequence TO be searched, // sequences AS "AANTT" will be considered palindromic. // // Parameters // $seq IS the sequence TO be searched // // Return // TRUE OR FALSE (1 OR 0) // // Requeriments: // None FUNCTION DNA_is_palindrome($seq) IF ($seq==RevComp_DNA2($seq)) RETURN TRUE; }else RETURN FALSE; } }
// Description FOR RevComp_DNA2 // Will yield the Reverse comlement OF a NA sequence. Allows degenerated nucleotides // // Parameters // $seq IS the sequence // // Return // A sequence // // Requeriments: // None FUNCTION RevComp_DNA2($seq) $seq= strtoupper($seq); $seq=strrev($seq); $seq=str_replace("A", "t", $seq); $seq=str_replace("T", "a", $seq); $seq=str_replace("G", "c", $seq); $seq=str_replace("C", "g", $seq); $seq=str_replace("Y", "r", $seq); $seq=str_replace("R", "y", $seq); $seq=str_replace("W", "w", $seq); $seq=str_replace("S", "s", $seq); $seq=str_replace("K", "m", $seq); $seq=str_replace("M", "k", $seq); $seq=str_replace("D", "h", $seq); $seq=str_replace("V", "b", $seq); $seq=str_replace("H", "d", $seq); $seq=str_replace("B", "v", $seq); $seq= strtoupper ($seq); RETURN $seq; }
// Description FOR remove_useless_from_DNA // Will remove non coding characters FROM a DNA sequence // // Parameters // $seq IS the sequence // // Return // A sequence // // Requeriments: // CountCount_ACGT,Count_YRWSKMDVHB FUNCTION remove_useless_from_DNA($seq)
$seq=strtoupper($seq); $seq=preg_replace("/\W|\d/","",$seq); $seq=preg_replace("/X/","N",$seq); $len_seq=strlen($seq); $number_ATGC=Count_ACGT($seq); $number_YRWSKMDVHB=Count_YRWSKMDVHB($seq); $number=$number_ATGC+$number_YRWSKMDVHB+substr_count($seq,"N"); IF ($number!=$len_seq)("Error:<BR>Sequence is not valid.<BR>At least one letter in the sequence is unknown (not a <a href=http://www.in-silico.com/s_restriction/Nucleotide_ambiguity_code.html>NC-UIBMB</a> valid code)");}
RETURN ($seq); }
// Description FOR Count_ACGT // Will count number OF A, C, G AND T bases IN the sequence // // Parameters // $seq IS the sequence // // Return // A number // // Requeriments: // None FUNCTION Count_ACGT($seq) $cg=substr_count($seq,"A")+substr_count($seq,"T")+substr_count($seq,"G")+substr_count($seq,"C"); RETURN $cg; }
// Description FOR Count_YRWSKMDVHB // Will count number OF degenerate nucleotides (Y, R, W, S, K, MD, V, H AND B) IN the sequence // // Parameters // $seq IS the sequence // // Return // A number // // Requeriments: // None FUNCTION Count_YRWSKMDVHB($c) $cg=substr_count($c,"Y")+substr_count($c,"R")+substr_count($c,"W")+substr_count($c,"S")+substr_count($c,"K")+substr_count($c,"M")+substr_count($c,"D")+substr_count($c,"V")+substr_count($c,"H")+substr_count($c,"B"); RETURN $cg; } PRINT>
|
je pense que je vais utiliser ceci pour l'adapter a Gambas
|
duocore | #3 Posté le 5/9/2013 à 23:56:47 |
---|
| j'ai modifié le code pour faire une fonction: inverser la chaine de caractere
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
| PUBLIC SUB Val_Click() DIM I, minimum, maximum AS INTEGER DIM LADN1 AS INTEGER DIM BASE1, BASE2 AS STRING
LADN1 = Len(ADN1.Text) IF (Comp.value = FALSE AND Rev.Value = FALSE) AND Pal.Value = FALSE THEN Message.Warning("Vous avez oublier de cocher une ou les 3 cases") ELSE IF Comp.Value = TRUE AND Rev.Value = TRUE THEN FOR I = 1 TO LADN1 BASE1 = Mid$(Upper$(ADN1.Text), I, 1) IF BASE1 = "A" THEN BASE2 = "T" ELSE IF BASE1 = "T" THEN BASE2 = "A" ELSE IF BASE1 = "G" THEN BASE2 = "C" ELSE IF BASE1 = "C" THEN BASE2 = "G" ENDIF ADN2.Text = BASE2 & ADN2.Text NEXT
ELSE IF Comp.Value = TRUE THEN FOR I = 1 TO LADN1 BASE1 = Mid$(Upper$(ADN1.Text), I, 1) IF BASE1 = "A" THEN BASE2 = "T" ELSE IF BASE1 = "T" THEN BASE2 = "A" ELSE IF BASE1 = "G" THEN BASE2 = "C" ELSE IF BASE1 = "C" THEN BASE2 = "G" ENDIF ADN2.Text = ADN2.Text & BASE2 NEXT
ELSE IF Rev.Value = TRUE THEN StrRev(ADN1.Text) 'FOR I = 1 TO LADN1 'BASE1 = Mid$(Upper$(ADN1.Text), I, 1) 'BASE2 = BASE1 'ADN2.Text = BASE2 & ADN2.Text NEXT
ENDIF IF Pal.Value = TRUE THEN ' inserer ici le code pour la recherche de palindrome
END
PUBLIC SUB mnuAbout_Click()
Licence.ShowModal
END
'PUBLIC SUB FUNCTION find_palindromic_seq(ADN1.TEXT AS String, minimum AS Integer, maximum AS Integer) 'result.Text = "" 'LADN1 = Len(ADN1.Text); 'FOR i = 0 TO ladn1 - minimum + 1 STEP 1 'j = minimum 'WHILE j < maximum + 1 AND (i + j) <= LADN1 'sub_seq = Mid$(ADN1.Text, i, j) 'IF (DNA_is_palindrome(sub_seq) == 1) THEN 'results[i] = sub_seq 'WEND 'j = j + 1 'ENDIF 'NEXT 'RETURN results 'END
'PUBLIC SUB FUNCTION DNA_is_palindrome(ADN1.Text) 'IF (ADN1.Text == RevComp_DNA2(ADN1.Text)) THEN 'RETURN TRUE ' ELSE 'RETURN FALSE 'ENDIF 'END
SUB FUNCTION StrRev(ADN1.Textas String) FOR I = 1 TO LADN1 BASE1 = Mid$(Upper$(ADN1.Text), I, 1) BASE2 = BASE1 ADN2.Text = BASE2 & ADN2.Text NEXT END
|
j'ai une erreur unexpeted "StrRev"
pouvez voux m'aider?
|
duocore | #4 Posté le 6/9/2013 à 22:18:52 |
---|
| je n'arrive pas a faire une fonction, et j'ai vu qu'il y a une fonction pour faire string[].reverse.
je ne sais pas comment faire.
aidez moi.
merci |
gambix | #5 Posté le 7/9/2013 à 14:54:36 |
---|
Faire simple ! | SUB FUNCTION StrRev(ADN1.Text as String) FOR I = 1 TO LADN1 BASE1 = Mid$(Upper$(ADN1.Text), I, 1) BASE2 = BASE1 ADN2.Text = BASE2 & ADN2.Text NEXT END
Bon c'est un peu pas clair...
pour commencer ... c'est quoi ça ? -> StrRev(ADN1.Text as String) ???
C'est une définition de fonction ou tu met l'argument passé dans la definition ... enfin un beau bazzard quoi !!
Bien Voici comment doit être la fonction :
1
2
3
4
5
6
7
8
9
10
11
| PRIVATE FUNCTION ReverseString(sVal AS STRING) AS STRING
DIM S AS STRING DIM i AS INTEGER FOR i = Len(sVal) TO 1 STEP -1 S &= Mid(sVal, i, 1) NEXT
RETURN S
END
|
ET Voici comment l'utiliser :
1
| RevADN.Text = ReverseString(ADN1.Text)
|
ou
1
| MachaineInversee = ReverseString(MaChaine)
|
Moins de texte dans une signature c'est agrandir son espace. |
duocore | #6 Posté le 8/9/2013 à 00:37:27 |
---|
| Merci pour l'aide
cela va m'aider pour la suite |