Commit 9ab9b555 authored by Mathieu Giraud's avatar Mathieu Giraud
Browse files

tests: update tests to use Germline and MultiGermline

Unit tests are passing again.
parent 859aedfe
......@@ -14,15 +14,17 @@ void testSegmentationBug1(int delta_min, int delta_max) {
Fasta seqV("../../germline/TRGV.fa");
Fasta seqJ("../../germline/TRGJ.fa");
IKmerStore<KmerAffect> *index = new ArrayKmerStore<KmerAffect>(k, rc);
index->insert(seqV, "V");
index->insert(seqJ, "J");
Germline *germline ;
germline = new Germline(seqV, seqV, seqJ, "##############", delta_min, delta_max);
MultiGermline *multi ;
multi = new MultiGermline(germline);
OnlineFasta input(buggy_sequences);
while (input.hasNext()) {
input.next();
KmerAffectAnalyser<KmerAffect> *kaa = new KmerAffectAnalyser<KmerAffect>(*index, input.getSequence().sequence);
KmerAffectAnalyser<KmerAffect> *kaa = new KmerAffectAnalyser<KmerAffect>(*(germline->index), input.getSequence().sequence);
set<KmerAffect> distinct_a = kaa->getDistinctAffectations();
int strand = 0;
......@@ -37,8 +39,8 @@ void testSegmentationBug1(int delta_min, int delta_max) {
}
}
Segmenter *segment = new KmerSegmenter(input.getSequence(), index,
delta_min, delta_max);
Segmenter *segment = new KmerSegmenter(input.getSequence(), multi);
if (strand == 2
|| (strand == 1
......@@ -52,7 +54,7 @@ void testSegmentationBug1(int delta_min, int delta_max) {
delete segment;
delete kaa;
}
delete index;
delete germline;
}
void testBugs() {
......
......@@ -2,6 +2,7 @@
#include <fstream>
#include <iostream>
#include <string>
#include "core/germline.h"
#include "core/kmerstore.h"
#include "core/dynprog.h"
#include "core/fasta.h"
......@@ -18,25 +19,28 @@ void testFineSegment()
Fasta data("../../data/Stanford_S22.fasta", 1, " ");
Germline *germline ;
germline = new Germline(seqV, seqD, seqJ, "####", 0, 50);
Sequence seq = data.read(2);
//segmentation VJ
FineSegmenter s(seq, seqV, seqJ, 0, 50, VDJ);
FineSegmenter s(seq, germline, VDJ);
TAP_TEST(s.isSegmented(), TEST_SEGMENT_POSITION, "is segmented (VJ)") ;
//segmentation D
s.FineSegmentD(seqV, seqD, seqJ);
s.FineSegmentD(germline);
TAP_TEST(s.isSegmented(), TEST_SEGMENT_POSITION, "is segmented (VDJ)") ;
// Revcomp sequence and tests that the results are the same.
seq.sequence = revcomp(seq.sequence);
FineSegmenter s2(seq, seqV, seqJ, 0, 50, VDJ);
FineSegmenter s2(seq, germline, VDJ);
TAP_TEST(s2.isSegmented(), TEST_SEGMENT_POSITION, "is segmented (VJ)") ;
//segmentation D
s2.FineSegmentD(seqV, seqD, seqJ);
s2.FineSegmentD(germline);
TAP_TEST(s2.isSegmented(), TEST_SEGMENT_POSITION, "is segmented (VDJ)") ;
TAP_TEST(s.getLeft() == s2.getLeft(), TEST_SEGMENT_REVCOMP, " left segmentation position");
......@@ -65,18 +69,22 @@ void testSegmentOverlap()
Fasta data("../../data/bug-segment-overlap.fa", 1, " ");
ArrayKmerStore<KmerAffect> index(10, true);
index.insert(seqV, "V");
index.insert(seqJ, "J");
Germline *germline1 ;
germline1 = new Germline(seqV, seqV, seqJ, "##########", -50, 50);
Germline *germline2 ;
germline2 = new Germline(seqV, seqV, seqJ, "##########", -50, 50);
MultiGermline *multi1 ;
multi1 = new MultiGermline(germline1);
for (int i = 0; i < data.size(); i++) {
KmerSegmenter ks(data.read(i), &index, 0, 100);
KmerSegmenter ks(data.read(i), multi1);
TAP_TEST(ks.seg_V + ks.seg_N + ks.seg_J == data.sequence(i)
|| ks.seg_V + ks.seg_N + ks.seg_J == revcomp(data.sequence(i)),
TEST_KMER_SEGMENT_OVERLAP,
" V= " << ks.seg_V << ", N = " << ks.seg_N << ", J = " << ks.seg_J);
FineSegmenter fs(data.read(i), seqV, seqJ, -50, 50, VDJ);
FineSegmenter fs(data.read(i), germline2, VDJ);
TAP_TEST(fs.seg_V + fs.seg_N + fs.seg_J == data.sequence(i)
|| fs.seg_V + fs.seg_N + fs.seg_J == revcomp(data.sequence(i)),
TEST_FINE_SEGMENT_OVERLAP,
......@@ -90,13 +98,16 @@ void testSegmentationCause() {
Fasta data("../../data/segmentation.fasta", 1, " ");
ArrayKmerStore<KmerAffect> index(10, true);
index.insert(seqV, "V");
index.insert(seqJ, "J");
Germline *germline ;
germline = new Germline(seqV, seqV, seqJ, "##########", 0, 10);
MultiGermline *multi ;
multi = new MultiGermline(germline);
int nb_checked = 0;
for (int i = 0; i < data.size(); i++) {
KmerSegmenter ks(data.read(i), &index, 0, 10);
KmerSegmenter ks(data.read(i), multi);
if (data.read(i).label == "seq-seg+") {
TAP_TEST(ks.isSegmented(), TEST_KMER_IS_SEGMENTED, "seq is " << data.label(i));
......@@ -178,9 +189,11 @@ void testExtractor() {
OnlineFasta data("../../data/segmentation.fasta", 1, " ");
ArrayKmerStore<KmerAffect> index(10, true);
index.insert(seqV, "V");
index.insert(seqJ, "J");
Germline *germline ;
germline = new Germline(seqV, seqV, seqJ, "##########", 0, 10);
MultiGermline *multi ;
multi = new MultiGermline(germline);
WindowExtractor we;
map<string, string> labels;
......@@ -189,7 +202,7 @@ void testExtractor() {
we.setSegmentedOutput(&out_seg);
we.setUnsegmentedOutput(&out_unseg);
WindowsStorage *ws = we.extract(&data, &index, 30, 0, 10, labels);
WindowsStorage *ws = we.extract(&data, multi, 30, labels);
TAP_TEST(we.getNbReads() == 11, TEST_EXTRACTOR_NB_READS, "");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment