File: given2seqEstimateTheDistanceK2P.cpp

package info (click to toggle)
fastml 3.11-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 5,772 kB
  • sloc: cpp: 48,522; perl: 3,588; ansic: 819; makefile: 386; python: 83; sh: 55
file content (57 lines) | stat: -rw-r--r-- 2,047 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include <fstream>
#include <iostream>
#include <string>
using namespace std;

#include "hky.h"
#include "sequence.h"
#include "distribution.h"
#include "stochasticProcess.h"
#include "uniDistribution.h"
#include "trivialAccelerator.h"
#include "sequenceContainer.h"
#include "nucleotide.h"
#include "phylipFormat.h"
#include "likeDist.h"
// NOTE: YOU MUST CHANGE THE NAME OF THE string seqFile TO MATCH YOUR OWN LOCATION OF THE SEQUENCE FILE NAME!

int main(int argc,char*argv[]) {
	cout<<"This program computes for the K2P model, when two sequences are given, the ML distance and its likelihood."<<endl;
	string seqFile = "s2l4_DNA.txt";
	distribution *dist =  new uniDistribution; 
	replacementModel *probMod1=new hky(0.25,0.25,0.25,0.25,0.5);
	pijAccelerator * pijAcc1 = new trivialAccelerator(probMod1); 
	replacementModel *probMod2=new hky(0.25,0.25,0.25,0.25,10);
	pijAccelerator * pijAcc2 = new trivialAccelerator(probMod2); 
	stochasticProcess sp1(dist, pijAcc1);
	stochasticProcess sp2(dist, pijAcc2);
	ifstream in(seqFile.c_str());
	if (!in) {errorMsg::reportError("unable to open input sequence file");}
	nucleotide myAlph; 
	sequenceContainer original = phylipFormat::read(in,&myAlph);
	const MDOUBLE myToll = 0.0001;
	if (original.numberOfSeqs() != 2) {
		errorMsg::reportError("for this check, there suppose to be only 2 sequences",1);
	}
	sequence s1 = original[0];
	sequence s2 = original[1];

	MDOUBLE resL1 = 0;
	likeDist likeDist1(sp1,myToll);
	MDOUBLE resD1 = likeDist1.giveDistance(s1,s2,NULL,&resL1);
	cout<<endl<<"For Tr/Tv = 0.5" <<endl;
	cout<<" the likelihood of these 2 sequences is:"<<resL1<<endl;
	cout<<" the ML distance between these 2 sequences is:"<<resD1<<endl;

	MDOUBLE resL2 = 0;
	likeDist likeDist2(sp2,myToll);
	MDOUBLE resD2 = likeDist2.giveDistance(s1,s2,NULL,&resL2);
	cout<<endl<<"For Tr/Tv = 10" <<endl;
	cout<<" the likelihood of these 2 sequences is:"<<resL2<<endl;
	cout<<" the ML distance between these 2 sequences is:"<<resD2<<endl;

	delete dist;
	delete probMod1;
	delete probMod2;
	return 0;
}