libStatGen Software  1
Main.cpp
1 #include <iostream>
2 #include <time.h>
3 #include "GenomeSequence.h"
4 #include "InputFile.h"
5 
6 void readDbsnp(mmapArrayBool_t& dbSNP, const char* fileName, GenomeSequence& ref);
7 
8 int main(int argc, char ** argv)
9 {
10  // time_t startTime;
11  // time_t endTime;
12  // startTime = time(NULL);
13  GenomeSequence* refPtr = new GenomeSequence("testFiles/chr1_partial.fa");
14  // endTime = time(NULL);
15 
16  // std::cerr << "Time to read reference: " << endTime - startTime << std::endl;
17  if(refPtr == NULL)
18  {
19  std::cerr << "Failed to read the reference\n";
20  return(-1);
21  }
22  std::cerr << "\nStandard VCF DBSNP test\n";
23  mmapArrayBool_t dbsnpArray1;
24  const char* dbsnpFileName = "testFiles/dbsnp.vcf";
25 
26  // startTime = time(NULL);
27  refPtr->loadDBSNP(dbsnpArray1, dbsnpFileName);
28  // endTime = time(NULL);
29  // std::cerr << "Time to read dbsnp through reference: " << endTime - startTime << std::endl;
30 
31 
32  genomeIndex_t mapPos =
33  refPtr->getGenomePosition("1", 10233);
34  std::cerr << "dbsnp " << mapPos << ": "
35  << dbsnpArray1[mapPos] << std::endl;
36  std::cerr << "dbsnp " << mapPos+1 << ": "
37  << dbsnpArray1[mapPos+1] << std::endl;
38  std::cerr << "dbsnp " << mapPos+2 << ": "
39  << dbsnpArray1[mapPos+2] << std::endl;
40 
41 
42  std::cerr << "\nGZIP VCF DBSNP test\n";
43 
44  mmapArrayBool_t dbsnpArray2;
45  dbsnpFileName = "testFiles/dbsnp.vcf.gz";
46 
47  // startTime = time(NULL);
48  refPtr->loadDBSNP(dbsnpArray2, dbsnpFileName);
49  // endTime = time(NULL);
50  // std::cerr << "Time to read dbsnp through reference: " << endTime - startTime << std::endl;
51 
52 
53  mapPos = refPtr->getGenomePosition("1", 10233);
54  std::cerr << "dbsnp " << mapPos << ": "
55  << dbsnpArray2[mapPos] << std::endl;
56  std::cerr << "dbsnp " << mapPos+1 << ": "
57  << dbsnpArray2[mapPos+1] << std::endl;
58  std::cerr << "dbsnp " << mapPos+2 << ": "
59  << dbsnpArray2[mapPos+2] << std::endl;
60  return(0);
61 }
Create/Access/Modify/Load Genome Sequences stored as binary mapped files.
bool loadDBSNP(mmapArrayBool_t &dbSNP, const char *inputFileName) const
user friendly dbSNP loader.
genomeIndex_t getGenomePosition(const char *chromosomeName, unsigned int chromosomeIndex) const
given a chromosome name and position, return the genome position