-
Notifications
You must be signed in to change notification settings - Fork 7
/
SNPs.h
111 lines (83 loc) · 2.97 KB
/
SNPs.h
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
// SNPs.h: SNPs in order of marker position along the chromosome
#ifndef SNPS_H
#define SNPS_H
#include "BasicDefinitions.h"
#include "NucleotideMap.h"
#include "SNP.h"
#include "SNPPositionMap.h"
#include "math.h"
#include <fstream>
#include <vector>
#include <string>
#include <map>
#include <list>
using namespace std;
class SNPs
{
public:
// SNPs(): default constructor
// Precondition: None.
// Postcondition: None.
SNPs();
unsigned int size();
unsigned int currentSize();
void setROI(string rsid[2]);
SNP getROIStart();
SNP getROIEnd();
string getChromosome();
void loadGeneticDistanceMap(string);
void setGeneticDistances();
// getSNP(): accessor for SNPS.
// Precondition: None.
// Postcondition: If snps has been populated and if markerPosition
// is within bounds of snps, then returns the SNP in markerPosition
// position of snps; otherwise issues a warning and returns an inactive SNP.
SNP getSNP(unsigned int markerPosition) const;
// Returns genetic distance if possible, otherwise returns physical distance (in MB)
float getDistance(unsigned int , unsigned int);
float getDistance(unsigned int , unsigned int , bool& genetic);
// getVariant(): accessor for variant alleles
// Precondition: None.
// Postcondition: If index is within bounds of snps and variant is 0 or 1,
// then returns the variant nucleotide that is mapped to variant in snp
// corresponding to index; otherwise issue a warning message and returns A.
char getVariant(unsigned int index, int variant) const;
int mapNucleotideToBinary(char nt, unsigned int index);
// processLegendFile(): parses HapMap legend file for markers
// Precondition: "info" contains valid .legend file name
// Postcondition: "snps" contains all SNP ids and positions, with counting starting at 0
void processLegendFile();
// processMAPFile(): parse PLINK .map file for markers
// Precondition: "info" contains valid .map file name
// Postcondition: "snps" contains all SNP ids and positions, with counting starting at 0
void processMAPFile();
bool setFile( string );
void print( ostream& );
void beginChromosome();
bool moreChromosome();
void nextChromosome();
private:
// stripWhiteSpace(): strips whitespace from stream
// Precondition: stream is a valid istream
// Postcondition: Leading whitespace has been stripped.
void stripWhiteSpace(ifstream& stream);
float getGeneticDistance( SNP );
void addSNP(SNP&);
int ROI_snp[2];
string ROI_id[2];
// info file
unsigned int full_size;
ifstream s;
string info;
NucleotideMap cnm;
// genetic map
map< string , map< string , float > > cm_map;
// snps
map< string , vector<SNP> > genome;
map< string , vector<SNP> >::iterator chromosome;
map< string , vector<SNP> >::iterator ROI_chromosome;
// keep a list of the chromosomes in input order
list< map< string , vector<SNP> >::iterator > chr_list;
};
#endif
// end SNPs.h