Ejemplo n.º 1
0
void test_addInEdge(){
	string a="AGCAAGTTAGCAACATCATATGAGTGCAATCCTGTTGTAGGCTCATCTAAGACATAAATAGTT";
	string b= "GCAAGTTAGCAACATCATATGAGTGCAATCCTGTTGTAGGCTCATCTAAGACATAAATAGTTT";
	int wordSize=a.length();

	Kmer aKmer=wordId(a.c_str());
	Kmer bKmer=wordId(b.c_str());

	Vertex bVertex;
	bVertex.constructor();
	bVertex.m_lowerKey=bKmer;
	bVertex.addIngoingEdge(&bKmer,&aKmer,wordSize);
	
	vector<Kmer>inEdges=bVertex.getIngoingEdges(&bKmer,wordSize);
	bool found=false;
	for(int j=0;j<(int)inEdges.size();j++){
		if(inEdges[j]==aKmer){
			found=true;
			break;
		}
	}
	if(!found){
		cout<<"Expected: "<<a<<endl;
		cout<<"Actual:"<<endl;
		cout<<inEdges.size()<<endl;
		for(int j=0;j<(int)inEdges.size();j++){
			cout<<inEdges[j].idToWord(wordSize,false)<<endl;
		}
	}
	assertEquals(inEdges.size(),1);
	assertEquals(found,true);
}
Ejemplo n.º 2
0
void test_addOutEdge(){
	string a="CAATAAGTAAAAAAGATTTTGTAACTTTCACAGCCTTATTTTTATCAATAGATACTGATAT";
	string b= "AATAAGTAAAAAAGATTTTGTAACTTTCACAGCCTTATTTTTATCAATAGATACTGATATT";
	int wordSize=a.length();

	Kmer aKmer=wordId(a.c_str());
	Kmer bKmer=wordId(b.c_str());

	Vertex aVertex;
	aVertex.constructor();
	Kmer lower=aKmer;
	Kmer aRC=aKmer.complementVertex(wordSize,false);

	if(aRC<lower){
		lower=aRC;
	}
	aVertex.m_lowerKey=lower;
	aVertex.addOutgoingEdge(&aKmer,&bKmer,wordSize);
	
	vector<Kmer>Edges=aVertex.getOutgoingEdges(&aKmer,wordSize);
	bool found=false;
	for(int j=0;j<(int)Edges.size();j++){
		if(Edges[j]==bKmer){
			found=true;
			break;
		}
	}
	if(!found){
		cout<<"Expected: "<<endl;
		cout<<b<<endl;
		cout<<"Actual:"<<endl;
		for(int j=0;j<(int)Edges.size();j++){
			cout<<Edges[j].idToWord(wordSize,false)<<endl;
		}
		uint8_t edges=aVertex.getEdges(&aKmer);
		cout<<"Edges"<<endl;
		print8(edges);
	}
	assertEquals(Edges.size(),1);
	assertEquals(found,true);
}