改来改去总是有两条红线,快崩溃了,请帮忙看下,拜谢!
#light
let query = [ 4; 3; 4; 1; 2; 2; 1; 2; 3; 4; 1; 4; 4; 1; 1; 2; 3; 1 ]
let size = 16
let protein = new ResizeArray<int>()
// Find the translation start codon
let rec startcodon x =
if query.[x] = 1 && query.[x+1] = 2 && query.[x+2] = 3 then x
else startcodon (x+1)
printfn "The translation starts at base pair %A" ((startcodon 0)+1)
// Find the translation start codon
let rec stopcodon x =
if (query.[x] = 2 && query.[x+1] = 1 && query.[x+2] = 1) ||
(query.[x] = 2 && query.[x+1] = 1 && query.[x+2] = 3) ||
(query.[x] = 2 && query.[x+1] = 3 && query.[x+2] = 1) then x
else stopcodon (x+1)
printfn "The translation stops at base pair %A" ((stopcodon 0)+1)
// Check whether the sequence legally contains both start and stop codon
let translationcheck a b =
if b - a > 0 && (b - a) % 3 = 0 then true
else false
let check1 =
if translationcheck (startcodon 0) (stopcodon 0) = true then
printfn "can be translated"
else printfn "The sequence does not contain legal start/stop positions!"
check1
// Translate the legal nucleotide sequence in to amino acid sequence
let translation a b =
let amino a =
match query.[a], query.[a+1], query.[a+2] with
| 1, 2, 3 -> 1
| 2, 2, 2 -> 2
| 2, 2, 4 -> 2
| 2, 2, 1 -> 3
| 2, 2, 3 -> 3
| 4, 2, 2 -> 3
| 4, 2, 4 -> 3
| 4, 2, 1 -> 3
| 4, 2, 3 -> 3
| 1, 2, 2 -> 4
| 1, 2, 4 -> 4
| 1, 2, 1 -> 4
| 3, 2, 2 -> 5
| 3, 2, 4 -> 5
| 3, 2, 1 -> 5
| 3, 2, 3 -> 5
| 2, 4, 2 -> 6
| 2, 4, 4 -> 6
| 2, 4, 1 -> 6
| 2, 4, 3 -> 6
| 1, 3, 2 -> 6
| 1, 3, 4 -> 6
| 4, 4, 2 -> 7
| 4, 4, 4 -> 7
| 4, 4, 1 -> 7
| 4, 4, 3 -> 7
| 1, 4, 2 -> 8
| 1, 4, 4 -> 8
| 1, 4, 1 -> 8
| 1, 4, 3 -> 8
| 3, 4, 2 -> 9
| 3, 4, 4 -> 9
| 3, 4, 1 -> 9
| 3, 4, 3 -> 9
| 2, 1, 2 -> 10
| 2, 1, 4 -> 10
| 4, 1, 2 -> 11
| 4, 1, 4 -> 11
| 4, 1, 1 -> 12
| 4, 1, 3 -> 12
| 1, 1, 2 -> 13
| 1, 1, 4 -> 13
| 1, 1, 1 -> 14
| 1, 1, 3 -> 14
| 3, 1, 2 -> 15
| 3, 1, 4 -> 15
| 3, 1, 1 -> 16
| 3, 1, 3 -> 16
| 2, 3, 2 -> 17
| 2, 3, 5 -> 17
| 2, 3, 3 -> 18
| 4, 3, 2 -> 19
| 4, 3, 4 -> 19
| 4, 3, 1 -> 19
| 4, 3, 3 -> 19
| 1, 3, 1 -> 19
| 1, 3, 3 -> 19
| 3, 3, 2 -> 20
| 3, 3, 4 -> 20
| 3, 3, 1 -> 20
| 3, 3, 3 -> 20
| 2, 1, 1 -> 0
| 2, 1, 3 -> 0
| 2, 3, 1 -> 0
let mutable x = a
while ( x <= b ) do
protein.Add(amino x);
x <- x + 3;
done;
// Covert protein array into amino acid sequence
translation (startcodon 0) (stopcodon 0)
protein.Remove(0)
printfn "%A" protein
let amino_acid x =
match x with
| 1 -> "Met"
| 2 -> "Phe"
| 3 -> "Leu"
| 4 -> "Ile"
| 5 -> "Val"
| 6 -> "Ser"
| 7 -> "Pro"
| 8 -> "Thr"
| 9 -> "Ala"
| 10 -> "Tyr"
| 11 -> "His"
| 12 -> "Gln"
| 13 -> "Asn"
| 14 -> "Lys"
| 15 -> "Asp"
| 16 -> "Glu"
| 17 -> "Cys"
| 18 -> "Trp"
| 19 -> "Arg"
| 20 -> "Gly"
let intoamino = List.map amino_acid query
printfn "%A" intoamino