Skip to content

Instantly share code, notes, and snippets.

import Bioinformatics.DNANucleotide as D
main = do
substrand <- getLine
putStrLn . concat . map show . reverse . map D.nucleotideComplement $ map D.charToDNANucleotide substrand
fac n = product [1..n]
combination 0 _ = 1
combination _ 0 = 1
combination n k =
let fn = fac n
fk = fac k
fnk = fac (n - k)
in fn / (fk * fnk)
@amonshiz
amonshiz / iprb.hs
Created January 16, 2015 03:15
Introduction to Mendelian Inheritance
mendelsFirstLaw :: Float -> Float -> Float -> Float
mendelsFirstLaw k m n = ((k**2 - k) + (2.0 * k * m) + (2.0 * k * n) + (m * n) + (0.75 * (m**2 - m))) / ((k + m + n) * (k + m + n - 1))
main = do
k <- getLine
m <- getLine
n <- getLine
putStrLn . show $ mendelsFirstLaw (read k :: Float) (read m :: Float) (read n :: Float)
#import "AppDelegate.h"
@interface AppDelegate ()
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
@amonshiz
amonshiz / Fibonacci.hs
Created January 25, 2015 00:46
Basic Fibonacci number implementation
fib :: Integer -> Integer
fib 0 = 0
fib 1 = 1
fib n = fib (n-1) + fib (n-2)
@amonshiz
amonshiz / fib.hs
Last active August 29, 2015 14:14
rabbitFib :: Integer -> Integer -> Integer
rabbitFib 0 _ = 0
rabbitFib 1 _ = 1
rabbitFib n k =
rabbitFib (n-1) k + k * rabbitFib (n-2) k
module Bioinformatics.DNANucleotide (
DNANucleotide (..),
charToDNANucleotide,
nucleotideComplement,
calculateGCContent
) where
import Data.Char
import Data.List
module Bioinformatics.RNANucleotide (
RNANucleotide (..),
charToRNANucleotide,
rnaToProtein
) where
import Data.Char
import Data.List
import qualified Data.Map as M
import qualified Data.Maybe as Mb
@amonshiz
amonshiz / DNANucleotide.hs
Created February 10, 2015 02:09
Finding a Motif in DNA
module Bioinformatics.DNANucleotide (
DNANucleotide (..),
charToDNANucleotide,
nucleotideComplement,
calculateGCContent,
findMotif
) where
import Data.Char
import Data.List
import qualified Bioinformatics.DNANucleotide as D
hammingDistance :: (Eq a) => [a] -> [a] -> Int
hammingDistance l1 l2 = sum . map (\(f,s) -> if f == s then 0 else 1) $ zip l1 l2
main = do
string1 <- getLine
string2 <- getLine
let dnaString1 = map D.charToDNANucleotide string1
let dnaString2 = map D.charToDNANucleotide string2