daily pastebin goal
4%
SHARE
TWEET

Untitled

a guest Jul 12th, 2018 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. module MolSeq where
  2.  
  3. import Hugs.Observe
  4. import Data.List
  5.  
  6. data SequenceType = DNA | Protein  
  7.     deriving (Show, Eq)
  8. data MolSeq = MolSeq { molSeqType :: SequenceType, molSeqName :: String, molSeqSequenceString :: String }
  9.     deriving (Show, Eq)
  10.    
  11.    
  12. string2seq :: String -> String -> MolSeq
  13. string2seq moleculeName seq
  14.         | isProtein seq = (MolSeq Protein moleculeName seq)
  15.         | otherwise = (MolSeq DNA moleculeName seq)
  16.             where
  17.                 isProtein :: String -> Bool
  18.                 isProtein [] = False
  19.                 isProtein (h:t)
  20.                     | (h `elem` "ACGTacgt") = isProtein t
  21.                     | otherwise = True
  22.        
  23.        
  24. seqName :: MolSeq -> String
  25. seqName mol = (molSeqName mol)
  26.  
  27. seqType :: MolSeq -> SequenceType
  28. seqName mol = (molSeqType mol)
  29.  
  30. seqLength :: MolSeq -> Int
  31. seqLength mol = length (molSeqSequenceString mol)
  32.  
  33. seqDistance :: MolSeq -> MolSeq -> Float
  34. seqDistance mol1 mol2
  35.         | compatibleMolecules mol1 mol2 = calcMolDistance mol1 mol2
  36.         | otherwise = error "'mol1' and 'mol2' are not of the same molecule type"
  37.        
  38.        
  39. compatibleMolecules :: MolSeq -> MolSeq -> Bool
  40. compatibleMolecules mol1 mol2 = (molSeqType mol1) = (molSeqType mol2)
  41.  
  42. calcMolDistance :: MolSeq -> MolSeq -> Float
  43. calcMolDistance mol1 mol2
  44.         | seqType mol1 == DNA = jukesCantor mol1 mol2
  45.         | otherwise = poisson mol1 mol2
  46.        
  47. jukesCantor :: MolSeq -> MolSeq -> Float
  48. jukesCantor mol1 mol2 = -(3/4)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top