@@ -10,9 +10,9 @@ import Prelude hiding (readFile, writeFile)
10
10
import System.Directory (removeFile )
11
11
import Test.Hspec
12
12
13
- import Bio.FASTA (fastaP , fromFile , toFile )
13
+ import Bio.FASTA (ParsableFastaToken , fastaP , fromFile , toFile )
14
14
import Bio.FASTA.Parser (parseOnly )
15
- import Bio.FASTA.Type (Fasta , FastaItem (.. ))
15
+ import Bio.FASTA.Type (Fasta , FastaItem (.. ), ModItem ( .. ), Modification ( .. ) )
16
16
import Bio.Sequence (bareSequence )
17
17
18
18
correctFasta1 :: Fasta Char
@@ -45,6 +45,16 @@ badFasta7 = Left "input.fasta:2:1:\n |\n2 | 5\8217-CTTCAAGAGAGAGACCTGCGT-3\8217
45
45
badFasta8 :: Either String (Fasta Char )
46
46
badFasta8 = Left " input.fasta:21:5:\n |\n 21 | CMV + enhMCK + prcTnT-2\r\n | ^^\n unexpected \" + \"\n expecting end of input, end of line, or letter\n "
47
47
48
+ correctFasta9 :: Fasta ModItem
49
+ correctFasta9 =
50
+ [ FastaItem " mol1" $ bareSequence [Mod (Unknown " [FAM]" ),Letter ' A' ,Letter ' C' ,Letter ' G' ,Letter ' T' ,Mod (Unknown " [UNK]" )]
51
+ , FastaItem " mol2" $ bareSequence [Mod (Unknown " [HEX]" ),Letter ' A' ,Letter ' C' ,Letter ' C' ,Letter ' G' ,Letter ' T' ]
52
+ , FastaItem " mol3" $ bareSequence [Mod (Unknown " [HEX]" ),Letter ' A' ,Letter ' C' ,Letter ' G' ,Letter ' T' ,Letter ' C' ,Letter ' A' ,Mod (Unknown " [UNK]" )]
53
+ ]
54
+
55
+ badFasta10 :: Either String (Fasta ModItem )
56
+ badFasta10 = Left " input.fasta:2:16:\n |\n 2|[FAM]ACGT[UNK][\n |^\n unexpectednewline\n expectingmodificationname\n "
57
+
48
58
fastaSpec :: Spec
49
59
fastaSpec = describe " Fasta files parser" $ do
50
60
describe " fromFile" $ do
@@ -56,19 +66,21 @@ fastaSpec = describe "Fasta files parser" $ do
56
66
parseBadFile " test/FASTA/order6.fasta" badFasta6
57
67
parseBadFile " test/FASTA/order7.fasta" badFasta7
58
68
parseBadFile " test/FASTA/order8.fasta" badFasta8
69
+ parseFile " test/FASTA/order9.fasta" correctFasta9
70
+ parseBadFile " test/FASTA/order10.fasta" badFasta10
59
71
60
72
describe " toFile" $ do
61
73
writeFile " test/FASTA/input.fasta" correctFasta5
62
74
writeFile " test/FASTA/input.fasta" correctFasta1
63
75
writeFile " test/FASTA/input.fasta" correctFasta3
64
76
65
- parseFile :: FilePath -> Fasta Char -> Spec
77
+ parseFile :: ( Show a , Eq a , ParsableFastaToken a ) => FilePath -> Fasta a -> Spec
66
78
parseFile path cf =
67
79
it (" correctly parses good fasta from file " <> path) $ do
68
80
fasta <- fromFile path
69
81
fasta `shouldBe` cf
70
82
71
- parseBadFile :: FilePath -> Either String (Fasta Char ) -> Spec
83
+ parseBadFile :: ( Show a , Eq a , ParsableFastaToken a ) => FilePath -> Either String (Fasta a ) -> Spec
72
84
parseBadFile path cf =
73
85
it (" correctly parses bad fasta from file " <> path) $ do
74
86
res <- liftIO (readFile path)
0 commit comments