Documentation ¶
Overview ¶
Package hw1b contains the answers to Programming for Lovers Homework 2 exercises. These exercises can be found on Stepik at https://stepik.org/course/59611/syllabus Definitions:
a DNA string or pattern is made up of the characters A, C, G, T representing each nucleotide a k-mer is simply DNA fragment of length k (i.e a substring) an (L, t)-clump: given integers L and t, a string Pattern forms an (L, t)-clump inside a (larger) string Genome if there is an interval of Genome of length L in which Pattern appears at least t times.
Index ¶
- func ClumpFinding(genome string, k, L, t int) []string
- func Complement(pattern string) string
- func ComplementChar(char rune) rune
- func ComplementOld(pattern string) string
- func Find(vs []int, val int) []int
- func FrequencyMap(text string, k int) map[string]int
- func FrequentWords(text string, k int) (freqWords []string)
- func MaxDict(dict map[string]int) int
- func MinimumSkew(genome string) []int
- func PatternCount(pattern, text string) (count int)
- func PatternMatching(pattern, text string) []int
- func Reduce(vs []int, f func(int, int) int) int
- func Reverse(text string) string
- func ReverseComplement(pattern string) string
- func SkewArray(genome string) []int
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ClumpFinding ¶
ClumpFinding takes a DNA string and finds all distinct k-mers forming (L, t)-clumps in the DNA.
func Complement ¶
Complement takes a DNA fragment as a text string and returns its complement The input should really only consist of ATCG characters. Other characters are passed unchanged
func ComplementChar ¶
ComplementChar take a single character representing a nucleotide (ATGC) and returns it's complement. Any character other than ATGC is returned unchanged
func ComplementOld ¶
ComplementOld takes a DNA fragment as a text string and returns its complement The input should really only consist of ATCG characters. Other characters are passed unchanged
func Find ¶
Find returns a slice of all positions of val in the slice vs. If there are no occurrences, an empty slice is returned.
func FrequencyMap ¶
FrequencyMap takes a text and returns all substrings (k-mers) of length k
func FrequentWords ¶
FrequentWords takes a text, returns the substrings, (words, k-mers) of length k that have the most occurrences. More than one word may have the same maximum occurrences, so we return a slice.
func MaxDict ¶
MaxDict finds the maximum of the int values in a map. It really does not care what the key is
func MinimumSkew ¶
MinimumSkew generates the skew for a DNA genone string, then finds the positions of the minimum skew
func PatternCount ¶
PatternCount takes a string text, and counts all occurances of pattern in text, including overlaps Note that this version only works with ASCII characters. It may mess up when Unicode characters are included
func PatternMatching ¶
PatternMatching returns a slice of integers indicating the starting position of each occurrence of pattern in text If there are no occurrences, and empty slice is returned. Overlapping patterns are counted multiple times
func Reduce ¶
Reduce returns the result of a pairwise application of the function through the slice The input slice must be at least length 2 NOTE: Copied from the package billsutil
func Reverse ¶
Reverse takes an ASCII text string and reverses it. Note that this simplistic version will *not* work for strings with Unicode characters!
func ReverseComplement ¶
ReverseComplement takes a DNA fragment as a text string and returns its reverse complement. The input should only consist of ATCG characters
func SkewArray ¶
SkewArray takes a string representing a DNA genome as input and outputs a skew array of G-C We keep a counter. Every time we see a G we increment a the counter, every time we see a C we decrement it. For A and R we do nothing. We output a int array the same length as the genome, replacing the necleotide letters with the skew counter. We append the counter to the array first, *then* modify it.
Types ¶
This section is empty.