13 lines
430 B
Plaintext
13 lines
430 B
Plaintext
// GCContent: the fraction of the letters of S that are G or C. Other letters
|
|
// (N for an unknown base, lowercase) count in the length and not in the count.
|
|
FUNCTION GCContent(S : STRING) RETURNS FLOAT
|
|
REQUIRE LENGTH(S) > 0
|
|
DECLARE Count : INTEGER <- 0
|
|
FOR I <- 0 TO LENGTH(S)
|
|
IF S[I] == 'G' OR S[I] == 'C' THEN
|
|
Count <- Count + 1
|
|
ENDIF
|
|
NEXT I
|
|
RETURN Count / LENGTH(S)
|
|
ENDFUNCTION
|