hw1b

package
v0.0.0-...-afa3bba Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 28, 2019 License: Unlicense Imports: 3 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClumpFinding

func ClumpFinding(genome string, k, L, t int) []string

ClumpFinding takes a DNA string and finds all distinct k-mers forming (L, t)-clumps in the DNA.

func Complement

func Complement(pattern string) string

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

func ComplementChar(char rune) rune

ComplementChar take a single character representing a nucleotide (ATGC) and returns it's complement. Any character other than ATGC is returned unchanged

func ComplementOld

func ComplementOld(pattern string) string

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

func Find(vs []int, val int) []int

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

func FrequencyMap(text string, k int) map[string]int

FrequencyMap takes a text and returns all substrings (k-mers) of length k

func FrequentWords

func FrequentWords(text string, k int) (freqWords []string)

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

func MaxDict(dict map[string]int) int

MaxDict finds the maximum of the int values in a map. It really does not care what the key is

func MinimumSkew

func MinimumSkew(genome string) []int

MinimumSkew generates the skew for a DNA genone string, then finds the positions of the minimum skew

func PatternCount

func PatternCount(pattern, text string) (count int)

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

func PatternMatching(pattern, text string) []int

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

func Reduce(vs []int, f func(int, int) int) int

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

func Reverse(text string) string

Reverse takes an ASCII text string and reverses it. Note that this simplistic version will *not* work for strings with Unicode characters!

func ReverseComplement

func ReverseComplement(pattern string) string

ReverseComplement takes a DNA fragment as a text string and returns its reverse complement. The input should only consist of ATCG characters

func SkewArray

func SkewArray(genome string) []int

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL