Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Bioinformatics: Pattern Count
let patternCount (text:string) (pattern:string) =
text
|> Seq.windowed pattern.Length
|> Seq.map(fun c -> new string(c))
|> Seq.filter(fun s -> s = pattern)
|> Seq.length
let text = "ACAACTCTGCATACTATCGGGAACTATCCT"
let pattern = "ACTAT"
patternCount text pattern
//For a larger test
let getRandomNuclotide () =
let dictionary = ["A";"C";"G";"T"]
let random = new Random()
dictionary.[random.Next(4)]
let getRandomSequence (length:int) =
let nuclotides = [ for i in 0 .. length -> getRandomNuclotide() ]
String.Join("", nuclotides)
let largerText = getRandomSequence 1000000000
let functionalCounts = patternCount largerText pattern
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.