Skip to content

Commit 4de799b

Browse files
committed
Added namespaces in each file and linked to popSTR.cpp. Added liblinear.cpp which has implementation of the liblinear functions used in popSTR.
1 parent bbdd96c commit 4de799b

10 files changed

Lines changed: 154 additions & 123 deletions

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/SeqAnHTS/
2+
/htslib-develop/
3+
/liblinear-2.01/
4+
/*.o
5+
/popSTR

Makefile

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,34 @@ BOOST_INCLUDE=/usr/include/boost # Change to your paths
55
BOOST_LIB=/usr/lib64
66
HTSLIB=$(PWD)/htslib-develop
77
SEQAN=$(PWD)/SeqAnHTS
8+
OBJS=liblinear.o popSTR.o msGenotyper.o computePnSlippage.o computeReadAttributes.o computePnSlippageDefault.o msGenotyperDefault.o
89

910
CXXFLAGS+=-I.
1011
CXXFLAGS+=-isystem $(SEQAN)/include
1112
CXXFLAGS+=-I$(HTSLIB)
1213
CXXFLAGS+=-isystem $(BOOST_INCLUDE)
13-
CXXFLAGS+=-pthread
14+
CXXFLAGS+=-pthread
1415
CXXFLAGS+=-Wfatal-errors
1516

16-
LDFLAGS=-g -L$(HTSLIB) -Wl,-rpath,$(HTSLIB) -lz -lhts -L$(BOOST_LIB) -Wl,-rpath,$(BOOST_LIB) -lboost_iostreams
17-
1817
# RELEASE build
19-
CXXFLAGS+=-O3 -DSEQAN_ENABLE_TESTING=0 -DSEQAN_ENABLE_DEBUG=0 -DSEQAN_HAS_ZLIB=1
18+
CXXFLAGS+=-O3
19+
LDFLAGS=-O3
2020

2121
#Debug build
22-
#CXXFLAGS+=-O0 -DSEQAN_ENABLE_TESTING=0 -DSEQAN_ENABLE_DEBUG=1 -DSEQAN_HAS_ZLIB=1
22+
#CXXFLAGS+=-g -O0
23+
#LDFLAGS=-g -O0
2324

2425
# set std to c++0x to allow using 'auto' etc.
25-
CXXFLAGS+=-std=c++0x
26+
CXXFLAGS+=-std=c++0x -DSEQAN_ENABLE_TESTING=0 -DSEQAN_ENABLE_DEBUG=0 -DSEQAN_HAS_ZLIB=1
27+
LDFLAGS+=-pthread -L$(HTSLIB) -Wl,-rpath,$(HTSLIB) -lz -lhts -L$(BOOST_LIB) -Wl,-rpath,$(BOOST_LIB) -lboost_iostreams
28+
29+
all: popSTR
30+
31+
%.o: %.cpp
32+
$(CXX) $(CXXFLAGS) -o $@ -c $<
33+
34+
popSTR: $(OBJS)
35+
$(CXX) -o $@ $(OBJS) $(LDFLAGS)
2636

27-
all: msGenotyper computePnSlippage computeReadAttributes getRefSeq computePnSlippageDefault msGenotyperDefault
37+
clean:
38+
rm -f $(OBJS)

computePnSlippage.cpp

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,12 @@
1212
#include <seqan/modifier.h>
1313
#include <seqan/stream.h>
1414
#include <seqan/arg_parse.h>
15-
#include <liblinear-2.01/linear.h>
16-
#include <liblinear-2.01/linear.cpp>
17-
#include <liblinear-2.01/tron.h>
18-
#include <liblinear-2.01/tron.cpp>
19-
#include <liblinear-2.01/blas/blas.h>
20-
#include <liblinear-2.01/blas/blasp.h>
21-
#include <liblinear-2.01/blas/daxpy.c>
22-
#include <liblinear-2.01/blas/ddot.c>
23-
#include <liblinear-2.01/blas/dnrm2.c>
24-
#include <liblinear-2.01/blas/dscal.c>
2515
#include <climits>
16+
#include <liblinear.hpp>
17+
18+
19+
namespace computePnSlippage
20+
{
2621

2722
using namespace std;
2823
using namespace seqan;
@@ -110,17 +105,17 @@ ArgumentParser::ParseResult parseCommandLine(ComputePnSlippageOptions & options,
110105
addOption(parser, ArgParseOption("MS", "markerSlippageFile", "A file containing slippage rates for the microsatellites, supplied when iterationNumber>0.", ArgParseArgument::INPUT_FILE, "IN-FILE"));
111106

112107
addOption(parser, ArgParseOption("MD", "regressionModelDirectory", "A directory where logistic regression models for all markers in the markerList are stored, supplied when iterationNumber>0.", ArgParseArgument::INPUTPREFIX, "IN-DIR"));
113-
108+
114109
ArgumentParser::ParseResult res = parse(parser, argc, argv);
115-
110+
116111
if (res != ArgumentParser::PARSE_OK)
117112
return res;
118-
113+
119114
getOptionValue(options.markerList, parser, "markerList");
120115
getOptionValue(options.attributesDirectory, parser, "attributesDirectory");
121116
getOptionValue(options.outputFile, parser, "outputFile");
122117
getOptionValue(options.iterationNumber, parser, "iterationNumber");
123-
getOptionValue(options.firstPnIdx, parser, "firstPnIdx");
118+
getOptionValue(options.firstPnIdx, parser, "firstPnIdx");
124119

125120
if (isSet(parser,"markerSlippageFile"))
126121
{
@@ -179,7 +174,7 @@ String<Marker> readMarkerList(CharString & markerInfoFile)
179174
markerFile >> currMarker.start;
180175
markerFile >> currMarker.end;
181176
markerFile >> currMarker.motif;
182-
177+
183178
appendValue(markers, currMarker);
184179
}
185180
return markers;
@@ -300,7 +295,7 @@ void readMarkerData_level2(CharString attributesDirectory, Marker& marker, map <
300295
long int offset = readOffSets(attsFile, firstPnIdx, firstPnIdx + pnToLabels.size() - 1);
301296
if (offset != 0)
302297
attsFile.seekg(offset);
303-
else
298+
else
304299
return;
305300
while (!attsFile.eof() && pnsFound < pnToLabels.size())
306301
{
@@ -372,7 +367,7 @@ void readMarkerData(CharString attributesDirectory, Marker & marker, map<string,
372367
long int offset = readOffSets(attsFile, firstPnIdx, firstPnIdx + pnToLabelProps.size()-1);
373368
if (offset < 1)
374369
return;
375-
else
370+
else
376371
attsFile.seekg(offset);
377372
//cout << "Finished seek command.\n";
378373
//variable declaration
@@ -453,7 +448,7 @@ void readMarkerData(CharString attributesDirectory, Marker & marker, map<string,
453448
}
454449
}
455450
else
456-
cerr << "Something went sideways while reading attributes @: " << attributesDirectory << "\n";
451+
cerr << "Something went sideways while reading attributes @: " << attributesDirectory << "\n";
457452
}
458453
}
459454

@@ -573,7 +568,7 @@ void readPnLabels(CharString modelAndLabelDir, CharString iterationNumber, map <
573568
labelFile.close();
574569
}
575570

576-
int main_2(int argc, char const ** argv)
571+
int main(int argc, char const ** argv)
577572
{
578573
ComputePnSlippageOptions options;
579574
ArgumentParser::ParseResult res = parseCommandLine(options, argc, argv);
@@ -593,7 +588,7 @@ int main_2(int argc, char const ** argv)
593588
//if iterationNumber == 0 just read data and "initialize" estimation
594589
if (options.iterationNumber == "0")
595590
{
596-
//read pns to estimate slippage for
591+
//read pns to estimate slippage for
597592
map<string, LabelProps> pnToLabelProps = readPnList(options.pnList);
598593
cout << "Finished reading " << pnToLabelProps.size() << " pns.\n";
599594

@@ -641,3 +636,5 @@ int main_2(int argc, char const ** argv)
641636

642637
return 0;
643638
}
639+
640+
} // namespace computePnSlippage

computePnSlippageDefault.cpp

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,10 @@
1212
#include <seqan/modifier.h>
1313
#include <seqan/stream.h>
1414
#include <seqan/arg_parse.h>
15-
#include <liblinear-2.01/linear.h>
16-
#include <liblinear-2.01/linear.cpp>
17-
#include <liblinear-2.01/tron.h>
18-
#include <liblinear-2.01/tron.cpp>
19-
#include <liblinear-2.01/blas/blas.h>
20-
#include <liblinear-2.01/blas/blasp.h>
21-
#include <liblinear-2.01/blas/daxpy.c>
22-
#include <liblinear-2.01/blas/ddot.c>
23-
#include <liblinear-2.01/blas/dnrm2.c>
24-
#include <liblinear-2.01/blas/dscal.c>
15+
#include <liblinear.hpp>
16+
17+
namespace computePnSlippageDefault
18+
{
2519

2620
using namespace std;
2721
using namespace seqan;
@@ -126,16 +120,16 @@ ArgumentParser::ParseResult parseCommandLine(ComputePnSlippageOptions & options,
126120

127121
addOption(parser, ArgParseOption("MD", "modelDirectory", "A directory where logistic regression models for all markers in the markerSlippageFile are stored.", ArgParseArgument::OUTPUT_FILE, "IN-DIR"));
128122
setRequired(parser, "modelDirectory");
129-
123+
130124
ArgumentParser::ParseResult res = parse(parser, argc, argv);
131-
125+
132126
if (res != ArgumentParser::PARSE_OK)
133127
return res;
134-
128+
135129
getOptionValue(options.pnList, parser, "pnList");
136130
getOptionValue(options.attributesDirectory, parser, "attributesDirectory");
137131
getOptionValue(options.outputFile, parser, "outputFile");
138-
getOptionValue(options.firstPnIdx, parser, "firstPnIdx");
132+
getOptionValue(options.firstPnIdx, parser, "firstPnIdx");
139133
getOptionValue(options.markerSlippageFile, parser, "markerSlippageFile");
140134
getOptionValue(options.modelDirectory, parser, "modelDirectory");
141135

@@ -301,7 +295,7 @@ double estimateSlippage(double current_sp, string pnId)
301295
{
302296
if ( marker.second.pnToPsum[pnId] == 0.0)
303297
continue;
304-
Pair<string, Marker> mapKey = Pair<string, Marker>(pnId, marker.first);
298+
Pair<string, Marker> mapKey = Pair<string, Marker>(pnId, marker.first);
305299
String<AttributeLine> readsAtI = markerAndPnToReads[mapKey];
306300
for (unsigned i=0; i<length(readsAtI); ++i)
307301
{
@@ -531,7 +525,7 @@ void readMarkerData(CharString attributesDirectory, Marker marker, map<string, L
531525
long int offset = readOffSets(attsFile, firstPnIdx, firstPnIdx + pnToLabelProps.size() - 1);
532526
if (offset != 0)
533527
attsFile.seekg(offset);
534-
else
528+
else
535529
return;
536530
while (!attsFile.eof() && pnsFound < pnToLabelProps.size())
537531
{
@@ -596,7 +590,7 @@ void readMarkerData(CharString attributesDirectory, Marker marker, map<string, L
596590
markerToAllelesAndGenotypes[marker].i2 = makeGenotypes(markerToAllelesAndGenotypes[marker].i1);
597591
}
598592

599-
int main_3(int argc, char const ** argv)
593+
int main(int argc, char const ** argv)
600594
{
601595
ComputePnSlippageOptions options;
602596
ArgumentParser::ParseResult res = parseCommandLine(options, argc, argv);
@@ -651,3 +645,5 @@ int main_3(int argc, char const ** argv)
651645
}
652646
return 0;
653647
}
648+
649+
} // namespace computePnSlippageDefault

computeReadAttributes.cpp

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ namespace std
3737
};
3838
}
3939

40+
41+
namespace computeReadAttributes
42+
{
43+
4044
//Structure to store marker information
4145
struct STRinfo {
4246
CharString chrom;
@@ -104,6 +108,8 @@ struct ReadPairInfo {
104108
CharString repSeq; //Repeat sequence in read
105109
} ;
106110

111+
} // namespace computeReadAttributes
112+
107113
namespace std
108114
{
109115

@@ -138,10 +144,10 @@ struct hash<seqan::Pair<int> >
138144
};
139145

140146
template <>
141-
struct hash<STRinfoSmall >
147+
struct hash<computeReadAttributes::STRinfoSmall >
142148
{
143149
std::size_t
144-
operator()(STRinfoSmall const & p) const
150+
operator()(computeReadAttributes::STRinfoSmall const & p) const
145151
{
146152
std::size_t seed = 42;
147153

@@ -174,6 +180,9 @@ struct hash<seqan::Triple<CharString, CharString, int> >
174180

175181
} // namespace std
176182

183+
namespace computeReadAttributes
184+
{
185+
177186
//Vector to check how many repeats I need to find in a read w.r.t. motif length
178187
std::vector<unsigned> repeatNumbers (6);
179188
//Vector to store my repeat purity demands w.r.t motif length.
@@ -1078,7 +1087,7 @@ Pair<Triple<CharString, CharString, int>,ReadInfo> setReference(BamAlignmentReco
10781087
return returnValue;
10791088
}
10801089

1081-
int main_1(int argc, char * argv[])
1090+
int main(int argc, char const ** argv)
10821091
{
10831092
time_t begin = time(0);
10841093
//Check arguments.
@@ -1634,4 +1643,6 @@ int main_1(int argc, char * argv[])
16341643
time_t end = time(0);
16351644
cout << "Total time: " << end - begin << "\n";
16361645
return 0;
1637-
}
1646+
}
1647+
1648+
} // namespace computeReadAttributes

liblinear.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#include <liblinear.hpp>
2+
3+
#include <liblinear-2.01/linear.cpp>
4+
#include <liblinear-2.01/tron.cpp>
5+
#include <liblinear-2.01/blas/daxpy.c>
6+
#include <liblinear-2.01/blas/ddot.c>
7+
#include <liblinear-2.01/blas/dnrm2.c>
8+
#include <liblinear-2.01/blas/dscal.c>

liblinear.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#pragma once
2+
3+
#include <liblinear-2.01/linear.h>
4+
#include <liblinear-2.01/tron.h>
5+
#include <liblinear-2.01/blas/blas.h>
6+
#include <liblinear-2.01/blas/blasp.h>

0 commit comments

Comments
 (0)