Skip to content

Commit

Permalink
added seed and version
Browse files Browse the repository at this point in the history
  • Loading branch information
grenaud committed Feb 8, 2023
1 parent 7ba3bbf commit 0a7f455
Show file tree
Hide file tree
Showing 7 changed files with 216 additions and 81 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ Contact your sequencing center or core and ask them to send you the sequence of
For single-end, no. For paired-end, mate have to be consecutive in the file (i.e. `First mate 1`, `second mate 1`, `First mate 2`, `second mate 2`, _etc.._ ). This can be done by either using raw data from the sequencer or sorting by name.

## Does my BAM file have to be unmapped?
BAM files can also be used to store unmapped reads. Ideally, leehom should be used prior to mapping since reads will map to a more accurate location if the adapters have been removed and overlapping stretches have been merged.
BAM files can also be used to store unmapped reads. leeHom should be used prior to mapping since reads will map to a more accurate location if the adapters have been removed and overlapping stretches have been merged.


## What do the `FF` tags in the BAM file mean?
Expand Down
2 changes: 1 addition & 1 deletion libgab
Submodule libgab updated 3 files
+1 −1 Makefile
+112 −43 libgab.h
+4 −0 testUtils.cpp
12 changes: 11 additions & 1 deletion src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,22 @@ all: ${BAMTOOLSLIBOBJ} ${LIBGABLIBOBJ} MergeTrimReads.o leeHom
%.o: %.cpp
${CXX} -c ${CXXFLAGS} $^

leeHom: leeHom.o MergeTrimReads.o ${LIBGABLIBOBJ}
version.h:
./get_version.sh

leeHom: version.h leeHom.o MergeTrimReads.o ${LIBGABLIBOBJ}
@echo "linking"
@echo ${LDLIBS}
@echo ${LDFLAGS}
${CXX} -o $@ $^ $(LDLIBS) $(LDFLAGS)

static: version.h leeHom.o MergeTrimReads.o ${LIBGABLIBOBJ}
@echo "staic linking"
@echo ${LDLIBS}
@echo ${LDFLAGS}
${CXX} -static -o leeHom $^ $(LDLIBS) $(LDFLAGS)


${LIBGABINC}/libgab.h:
rm -rf ../libgab/
mkdir ../libgab/
Expand Down
22 changes: 15 additions & 7 deletions src/MergeTrimReads.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -411,12 +411,18 @@ void MergeTrimReads::initMerge(){
inline double MergeTrimReads::randomGen(){
// static bool initialized = false;


if(initialized == false){
struct timeval time;
gettimeofday(&time,NULL);
srand(time.tv_usec);
if(seedSpecified){
srand(seed);
}else{
//use time of day as seed
struct timeval time;
gettimeofday(&time,NULL);
srand(time.tv_usec);
}
initialized=true;
return (double(rand())/double(RAND_MAX));
return (double(rand())/double(RAND_MAX));
}else{
return (double(rand())/double(RAND_MAX));
}
Expand Down Expand Up @@ -2058,8 +2064,8 @@ MergeTrimReads::MergeTrimReads (const string& forward_, const string& reverse_,
const string& key1_, const string& key2_,
const bool trimKey_,
const string& ikey_,
int trimcutoff_,bool allowMissing_,
bool ancientDNA_,double location_,double scale_,bool useDist_,int qualOffset):
const int trimcutoff_,const bool allowMissing_,
const bool ancientDNA_,const double location_,const double scale_,const bool useDist_,const int qualOffset,const unsigned int seed_,const bool seedSpecified_):
//bool mergeoverlap_) :
min_length (5),
qualOffset (qualOffset),
Expand All @@ -2075,7 +2081,9 @@ MergeTrimReads::MergeTrimReads (const string& forward_, const string& reverse_,

location(location_),
scale(scale_),
useDist(useDist_)
useDist(useDist_),
seed(seed_),
seedSpecified(seedSpecified_)
{

initialized = false;
Expand Down
11 changes: 10 additions & 1 deletion src/MergeTrimReads.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ class MergeTrimReads{

size_t min_overlap_seqs;

unsigned int seed;
bool seedSpecified;

/* // Key variables /// */
bool handle_key;
Expand Down Expand Up @@ -302,7 +304,14 @@ class MergeTrimReads{
public:
MergeTrimReads (const string& forward_, const string& reverse_, const string& chimera_,
const string& key1_="", const string& key2_="",const bool trimKey_=false,const string& ikey_="",
int trimcutoff_=1,bool allowMissing_=false,bool ancientDNA_=false,double location_=-1.0,double scale_=-1.0,bool useDist_=false,int qualOffset=33);
const int trimcutoff_=1,
const bool allowMissing_=false,
const bool ancientDNA_=false,
const double location_=-1.0,
const double scale_=-1.0,
const bool useDist_=false,
const int qualOffset=33,
const unsigned int seed=0,const bool seedSpecified=false);

MergeTrimReads(const MergeTrimReads & other);
~MergeTrimReads();
Expand Down
9 changes: 9 additions & 0 deletions src/get_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

version=$(git describe --tags $(git rev-list --tags --max-count=1))

if [ $? -eq 0 ]; then
echo "#define VERSION \"$version\"" > version.h
else
echo "#define VERSION "NA"" > version.h
fi
Loading

0 comments on commit 0a7f455

Please sign in to comment.