Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
R3
legacy
bedtools2
Commits
ed38d473
Commit
ed38d473
authored
May 16, 2015
by
arq5x
Browse files
merge cleanup
parents
cbad1fc5
84a4f059
Changes
116
Hide whitespace changes
Inline
Side-by-side
Makefile
View file @
ed38d473
...
...
@@ -37,7 +37,7 @@ SUBDIRS = $(SRC_DIR)/annotateBed \
$(SRC_DIR)
/closestFile
\
$(SRC_DIR)
/clusterBed
\
$(SRC_DIR)
/complementBed
\
$(SRC_DIR)
/coverage
Bed
\
$(SRC_DIR)
/coverage
File
\
$(SRC_DIR)
/expand
\
$(SRC_DIR)
/fastaFromBed
\
$(SRC_DIR)
/flankBed
\
...
...
@@ -79,6 +79,8 @@ UTIL_SUBDIRS = $(SRC_DIR)/utils/bedFile \
$(SRC_DIR)
/utils/chromsweep
\
$(SRC_DIR)
/utils/Contexts
\
$(SRC_DIR)
/utils/FileRecordTools
\
$(SRC_DIR)
/utils/FileRecordTools/FileReaders
\
$(SRC_DIR)
/utils/FileRecordTools/Records
\
$(SRC_DIR)
/utils/general
\
$(SRC_DIR)
/utils/gzstream
\
$(SRC_DIR)
/utils/fileType
\
...
...
@@ -93,15 +95,47 @@ UTIL_SUBDIRS = $(SRC_DIR)/utils/bedFile \
$(SRC_DIR)
/utils/Fasta
\
$(SRC_DIR)
/utils/VectorOps
\
$(SRC_DIR)
/utils/GenomeFile
\
$(SRC_DIR)
/utils/RecordOutputMgr
$(SRC_DIR)
/utils/RecordOutputMgr
\
$(SRC_DIR)
/utils/ToolBase
\
$(SRC_DIR)
/utils/aux
BUILT_OBJECTS
=
$(OBJ_DIR)
/
*
.o
INCLUDES
=
-I
$(SRC_DIR)
/utils/bedFile
\
-I
$(SRC_DIR)
/utils/BinTree
\
-I
$(SRC_DIR)
/utils/version
\
-I
$(SRC_DIR)
/utils/bedGraphFile
\
-I
$(SRC_DIR)
/utils/chromsweep
\
-I
$(SRC_DIR)
/utils/Contexts
\
-I
$(SRC_DIR)
/utils/FileRecordTools
\
-I
$(SRC_DIR)
/utils/FileRecordTools/FileReaders
\
-I
$(SRC_DIR)
/utils/FileRecordTools/Records
\
-I
$(SRC_DIR)
/utils/general
\
-I
$(SRC_DIR)
/utils/gzstream
\
-I
$(SRC_DIR)
/utils/fileType
\
-I
$(SRC_DIR)
/utils/bedFilePE
\
-I
$(SRC_DIR)
/utils/KeyListOps
\
-I
$(SRC_DIR)
/utils/NewChromsweep
\
-I
$(SRC_DIR)
/utils/sequenceUtilities
\
-I
$(SRC_DIR)
/utils/tabFile
\
-I
$(SRC_DIR)
/utils/BamTools
\
-I
$(SRC_DIR)
/utils/BamTools/include
\
-I
$(SRC_DIR)
/utils/BamTools/src
\
-I
$(SRC_DIR)
/utils/BamTools-Ancillary
\
-I
$(SRC_DIR)
/utils/BlockedIntervals
\
-I
$(SRC_DIR)
/utils/Fasta
\
-I
$(SRC_DIR)
/utils/VectorOps
\
-I
$(SRC_DIR)
/utils/GenomeFile
\
-I
$(SRC_DIR)
/utils/RecordOutputMgr
\
-I
$(SRC_DIR)
/utils/ToolBase
\
-I
$(SRC_DIR)
/utils/aux
\
all
:
print_banner $(OBJ_DIR) $(BIN_DIR) autoversion $(UTIL_SUBDIRS) $(SUBDIRS)
@
echo
"- Building main bedtools binary."
@
$(CXX)
$(CXXFLAGS)
-c
src/bedtools.cpp
-o
obj/bedtools.o
-I
$(UTIL_DIR)
/version/
@
$(CXX)
$(CXXFLAGS)
-o
$(BIN_DIR)
/bedtools
$(BUILT_OBJECTS)
-L
$(UTIL_DIR)
/BamTools/lib/
-lbamtools
$(LIBS)
$(LDFLAGS)
@
$(CXX)
$(CXXFLAGS)
-c
src/bedtools.cpp
-o
obj/bedtools.o
$(INCLUDES)
@
$(CXX)
$(CXXFLAGS)
-o
$(BIN_DIR)
/bedtools
$(BUILT_OBJECTS)
-L
$(UTIL_DIR)
/BamTools/lib/
-lbamtools
$(LIBS)
$(LDFLAGS)
$(INCLUDES)
@
echo
"done."
@
echo
"- Creating executables for old CLI."
...
...
src/bedtools.cpp
View file @
ed38d473
...
...
@@ -17,8 +17,8 @@
#include
<iostream>
#include
<fstream>
#include
<stdlib.h>
#include
<string>
#include
"version.h"
#include
"BedtoolsDriver.h"
using
namespace
std
;
...
...
@@ -34,6 +34,9 @@ using namespace std;
// define our parameter checking macro
#define PARAMETER_CHECK(param, paramLen, actualLen) (strncmp(argv[i], param, min(actualLen, paramLen))== 0) && (actualLen == paramLen)
bool
sub_main
(
const
QuickString
&
subCmd
);
void
showHelp
(
const
QuickString
&
subCmd
);
int
annotate_main
(
int
argc
,
char
*
argv
[]);
//
int
bamtobed_main
(
int
argc
,
char
*
argv
[]);
//
int
bamtofastq_main
(
int
argc
,
char
*
argv
[]);
//
...
...
@@ -41,10 +44,10 @@ int bed12tobed6_main(int argc, char* argv[]); //
int
bedtobam_main
(
int
argc
,
char
*
argv
[]);
//
int
bedtoigv_main
(
int
argc
,
char
*
argv
[]);
//
int
bedpetobam_main
(
int
argc
,
char
*
argv
[]);
//
int
closest_
main
(
int
argc
,
char
*
argv
[]);
//
void
closest_
help
();
int
cluster_main
(
int
argc
,
char
*
argv
[]);
//
int
complement_main
(
int
argc
,
char
*
argv
[]);
//
int
coverage_
main
(
int
argc
,
char
*
argv
[]);
//
void
coverage_
help
();
int
regress_test_main
(
int
argc
,
char
**
argv
);
//
int
expand_main
(
int
argc
,
char
*
argv
[]);
//
int
fastafrombed_main
(
int
argc
,
char
*
argv
[]);
//
...
...
@@ -52,13 +55,14 @@ int flank_main(int argc, char* argv[]); //
int
genomecoverage_main
(
int
argc
,
char
*
argv
[]);
//
int
getoverlap_main
(
int
argc
,
char
*
argv
[]);
//
int
groupby_main
(
int
argc
,
char
*
argv
[]);
//
int
intersect_main
(
int
argc
,
char
*
argv
[]);
//
int
jaccard_main
(
int
argc
,
char
*
argv
[]);
//
int
fisher_main
(
int
argc
,
char
*
argv
[]);
//
void
intersect_help
();
void
map_help
();
void
jaccard_help
();
//
void
fisher_help
();
int
links_main
(
int
argc
,
char
*
argv
[]);
//
int
maskfastafrombed_main
(
int
argc
,
char
*
argv
[]);
//
int
map_main
(
int
argc
,
char
*
argv
[]);
//
int
merge_
main
(
int
argc
,
char
*
argv
[]);
//
void
merge_
help
();
int
multibamcov_main
(
int
argc
,
char
*
argv
[]);
//
int
multiintersect_main
(
int
argc
,
char
*
argv
[]);
//
int
nek_sandbox1_main
(
int
argc
,
char
*
argv
[]);
//
...
...
@@ -67,13 +71,13 @@ int pairtobed_main(int argc, char* argv[]);//
int
pairtopair_main
(
int
argc
,
char
*
argv
[]);
//
int
random_main
(
int
argc
,
char
*
argv
[]);
//
int
reldist_main
(
int
argc
,
char
*
argv
[]);
//
int
sample_
main
(
int
argc
,
char
*
argv
[]);
//
void
sample_
help
();
int
shuffle_main
(
int
argc
,
char
*
argv
[]);
//
int
slop_main
(
int
argc
,
char
*
argv
[]);
//
int
split_main
(
int
argc
,
char
*
argv
[]);
//
int
sort_main
(
int
argc
,
char
*
argv
[]);
//
int
spacing_
main
(
int
argc
,
char
*
argv
[]);
//
int
subtract_
main
(
int
argc
,
char
*
argv
[]);
//
void
spacing_
help
();
void
subtract_
help
();
int
tagbam_main
(
int
argc
,
char
*
argv
[]);
//
int
unionbedgraphs_main
(
int
argc
,
char
*
argv
[]);
//
int
window_main
(
int
argc
,
char
*
argv
[]);
//
...
...
@@ -87,83 +91,82 @@ int main(int argc, char *argv[])
// make sure the user at least entered a sub_command
if
(
argc
<
2
)
return
bedtools_help
();
std
::
string
sub_cmd
=
argv
[
1
];
QuickString
subCmd
(
argv
[
1
]);
BedtoolsDriver
btDriver
;
if
(
btDriver
.
supports
(
subCmd
))
{
if
(
btDriver
.
subMain
(
argc
,
argv
))
{
return
0
;
}
else
{
showHelp
(
subCmd
);
return
1
;
}
}
// genome arithmetic tools
if
(
sub_cmd
==
"intersect"
)
return
intersect_main
(
argc
-
1
,
argv
+
1
);
else
if
(
sub_cmd
==
"window"
)
return
window_main
(
argc
-
1
,
argv
+
1
);
else
if
(
sub_cmd
==
"closest"
)
return
closest_main
(
argc
-
1
,
argv
+
1
);
else
if
(
sub_cmd
==
"coverage"
)
return
coverage_main
(
argc
-
1
,
argv
+
1
);
else
if
(
sub_cmd
==
"map"
)
return
map_main
(
argc
-
1
,
argv
+
1
);
else
if
(
sub_cmd
==
"genomecov"
)
return
genomecoverage_main
(
argc
-
1
,
argv
+
1
);
else
if
(
sub_cmd
==
"merge"
)
return
merge_main
(
argc
-
1
,
argv
+
1
);
else
if
(
sub_cmd
==
"cluster"
)
return
cluster_main
(
argc
-
1
,
argv
+
1
);
else
if
(
sub_cmd
==
"complement"
)
return
complement_main
(
argc
-
1
,
argv
+
1
);
else
if
(
sub_cmd
==
"subtract"
)
return
subtract_main
(
argc
-
1
,
argv
+
1
);
else
if
(
sub_cmd
==
"slop"
)
return
slop_main
(
argc
-
1
,
argv
+
1
);
else
if
(
sub_cmd
==
"split"
)
return
split_main
(
argc
-
1
,
argv
+
1
);
else
if
(
sub_cmd
==
"flank"
)
return
flank_main
(
argc
-
1
,
argv
+
1
);
else
if
(
sub_cmd
==
"sort"
)
return
sort_main
(
argc
-
1
,
argv
+
1
);
else
if
(
sub_cmd
==
"random"
)
return
random_main
(
argc
-
1
,
argv
+
1
);
else
if
(
sub_cmd
==
"shuffle"
)
return
shuffle_main
(
argc
-
1
,
argv
+
1
);
else
if
(
sub_cmd
==
"spacing"
)
return
spacing_main
(
argc
-
1
,
argv
+
1
);
else
if
(
sub_cmd
==
"annotate"
)
return
annotate_main
(
argc
-
1
,
argv
+
1
);
else
if
(
subCmd
==
"window"
)
return
window_main
(
argc
-
1
,
argv
+
1
);
else
if
(
subCmd
==
"genomecov"
)
return
genomecoverage_main
(
argc
-
1
,
argv
+
1
);
else
if
(
subCmd
==
"cluster"
)
return
cluster_main
(
argc
-
1
,
argv
+
1
);
else
if
(
subCmd
==
"complement"
)
return
complement_main
(
argc
-
1
,
argv
+
1
);
else
if
(
subCmd
==
"slop"
)
return
slop_main
(
argc
-
1
,
argv
+
1
);
else
if
(
subCmd
==
"split"
)
return
split_main
(
argc
-
1
,
argv
+
1
);
else
if
(
subCmd
==
"flank"
)
return
flank_main
(
argc
-
1
,
argv
+
1
);
else
if
(
subCmd
==
"sort"
)
return
sort_main
(
argc
-
1
,
argv
+
1
);
else
if
(
subCmd
==
"random"
)
return
random_main
(
argc
-
1
,
argv
+
1
);
else
if
(
subCmd
==
"shuffle"
)
return
shuffle_main
(
argc
-
1
,
argv
+
1
);
else
if
(
subCmd
==
"annotate"
)
return
annotate_main
(
argc
-
1
,
argv
+
1
);
// Multi-way file comparisonstools
else
if
(
sub
_c
md
==
"multiinter"
)
return
multiintersect_main
(
argc
-
1
,
argv
+
1
);
else
if
(
sub
_c
md
==
"unionbedg"
)
return
unionbedgraphs_main
(
argc
-
1
,
argv
+
1
);
else
if
(
sub
C
md
==
"multiinter"
)
return
multiintersect_main
(
argc
-
1
,
argv
+
1
);
else
if
(
sub
C
md
==
"unionbedg"
)
return
unionbedgraphs_main
(
argc
-
1
,
argv
+
1
);
// paired-end conversion tools
else
if
(
sub
_c
md
==
"pairtobed"
)
return
pairtobed_main
(
argc
-
1
,
argv
+
1
);
else
if
(
sub
_c
md
==
"pairtopair"
)
return
pairtopair_main
(
argc
-
1
,
argv
+
1
);
else
if
(
sub
C
md
==
"pairtobed"
)
return
pairtobed_main
(
argc
-
1
,
argv
+
1
);
else
if
(
sub
C
md
==
"pairtopair"
)
return
pairtopair_main
(
argc
-
1
,
argv
+
1
);
// format conversion tools
else
if
(
sub
_c
md
==
"bamtobed"
)
return
bamtobed_main
(
argc
-
1
,
argv
+
1
);
else
if
(
sub
_c
md
==
"bedtobam"
)
return
bedtobam_main
(
argc
-
1
,
argv
+
1
);
else
if
(
sub
_c
md
==
"bamtofastq"
)
return
bamtofastq_main
(
argc
-
1
,
argv
+
1
);
else
if
(
sub
_c
md
==
"bedpetobam"
)
return
bedpetobam_main
(
argc
-
1
,
argv
+
1
);
else
if
(
sub
_c
md
==
"bed12tobed6"
)
return
bed12tobed6_main
(
argc
-
1
,
argv
+
1
);
else
if
(
sub
C
md
==
"bamtobed"
)
return
bamtobed_main
(
argc
-
1
,
argv
+
1
);
else
if
(
sub
C
md
==
"bedtobam"
)
return
bedtobam_main
(
argc
-
1
,
argv
+
1
);
else
if
(
sub
C
md
==
"bamtofastq"
)
return
bamtofastq_main
(
argc
-
1
,
argv
+
1
);
else
if
(
sub
C
md
==
"bedpetobam"
)
return
bedpetobam_main
(
argc
-
1
,
argv
+
1
);
else
if
(
sub
C
md
==
"bed12tobed6"
)
return
bed12tobed6_main
(
argc
-
1
,
argv
+
1
);
// BAM-specific tools
else
if
(
sub
_c
md
==
"multicov"
)
return
multibamcov_main
(
argc
-
1
,
argv
+
1
);
else
if
(
sub
_c
md
==
"tag"
)
return
tagbam_main
(
argc
-
1
,
argv
+
1
);
else
if
(
sub
C
md
==
"multicov"
)
return
multibamcov_main
(
argc
-
1
,
argv
+
1
);
else
if
(
sub
C
md
==
"tag"
)
return
tagbam_main
(
argc
-
1
,
argv
+
1
);
// fasta tools
else
if
(
sub
_c
md
==
"getfasta"
)
return
fastafrombed_main
(
argc
-
1
,
argv
+
1
);
else
if
(
sub
_c
md
==
"maskfasta"
)
return
maskfastafrombed_main
(
argc
-
1
,
argv
+
1
);
else
if
(
sub
_c
md
==
"nuc"
)
return
nuc_main
(
argc
-
1
,
argv
+
1
);
else
if
(
sub
C
md
==
"getfasta"
)
return
fastafrombed_main
(
argc
-
1
,
argv
+
1
);
else
if
(
sub
C
md
==
"maskfasta"
)
return
maskfastafrombed_main
(
argc
-
1
,
argv
+
1
);
else
if
(
sub
C
md
==
"nuc"
)
return
nuc_main
(
argc
-
1
,
argv
+
1
);
// statistics tools
else
if
(
sub_cmd
==
"jaccard"
)
return
jaccard_main
(
argc
-
1
,
argv
+
1
);
else
if
(
sub_cmd
==
"reldist"
)
return
reldist_main
(
argc
-
1
,
argv
+
1
);
else
if
(
sub_cmd
==
"fisher"
)
return
fisher_main
(
argc
-
1
,
argv
+
1
);
else
if
(
subCmd
==
"reldist"
)
return
reldist_main
(
argc
-
1
,
argv
+
1
);
// misc. tools
else
if
(
sub_cmd
==
"overlap"
)
return
getoverlap_main
(
argc
-
1
,
argv
+
1
);
else
if
(
sub_cmd
==
"igv"
)
return
bedtoigv_main
(
argc
-
1
,
argv
+
1
);
else
if
(
sub_cmd
==
"links"
)
return
links_main
(
argc
-
1
,
argv
+
1
);
else
if
(
sub_cmd
==
"makewindows"
)
return
windowmaker_main
(
argc
-
1
,
argv
+
1
);
else
if
(
sub_cmd
==
"groupby"
)
return
groupby_main
(
argc
-
1
,
argv
+
1
);
else
if
(
sub_cmd
==
"expand"
)
return
expand_main
(
argc
-
1
,
argv
+
1
);
else
if
(
sub_cmd
==
"sample"
)
return
sample_main
(
argc
-
1
,
argv
+
1
);
else
if
(
sub_cmd
==
"neksb1"
)
return
nek_sandbox1_main
(
argc
-
1
,
argv
+
1
);
else
if
(
sub_cmd
==
"regresstest"
)
return
regress_test_main
(
argc
,
argv
);
//this command does need all the orig args.
else
if
(
subCmd
==
"overlap"
)
return
getoverlap_main
(
argc
-
1
,
argv
+
1
);
else
if
(
subCmd
==
"igv"
)
return
bedtoigv_main
(
argc
-
1
,
argv
+
1
);
else
if
(
subCmd
==
"links"
)
return
links_main
(
argc
-
1
,
argv
+
1
);
else
if
(
subCmd
==
"makewindows"
)
return
windowmaker_main
(
argc
-
1
,
argv
+
1
);
else
if
(
subCmd
==
"groupby"
)
return
groupby_main
(
argc
-
1
,
argv
+
1
);
else
if
(
subCmd
==
"expand"
)
return
expand_main
(
argc
-
1
,
argv
+
1
);
else
if
(
subCmd
==
"neksb1"
)
return
nek_sandbox1_main
(
argc
-
1
,
argv
+
1
);
else
if
(
subCmd
==
"regresstest"
)
return
regress_test_main
(
argc
,
argv
);
//this command does need all the orig args.
// help
else
if
(
sub
_c
md
==
"-h"
||
sub
_c
md
==
"--help"
||
sub
_c
md
==
"-help"
)
else
if
(
sub
C
md
==
"-h"
||
sub
C
md
==
"--help"
||
sub
C
md
==
"-help"
)
return
bedtools_help
();
// frequently asked questions
else
if
(
sub
_c
md
==
"--FAQ"
||
sub
_c
md
==
"--faq"
||
sub
_c
md
==
"-FAQ"
||
sub
_c
md
==
"-faq"
)
else
if
(
sub
C
md
==
"--FAQ"
||
sub
C
md
==
"--faq"
||
sub
C
md
==
"-FAQ"
||
sub
C
md
==
"-faq"
)
return
bedtools_faq
();
// verison information
else
if
(
sub
_c
md
==
"-version"
||
sub
_c
md
==
"--version"
)
else
if
(
sub
C
md
==
"-version"
||
sub
C
md
==
"--version"
)
cout
<<
"bedtools "
<<
VERSION
<<
endl
;
// verison information
else
if
(
sub
_c
md
==
"-contact"
||
sub
_c
md
==
"--contact"
)
else
if
(
sub
C
md
==
"-contact"
||
sub
C
md
==
"--contact"
)
{
cout
<<
endl
;
cout
<<
"- For further help, or to report a bug, please "
<<
endl
;
...
...
@@ -282,3 +285,28 @@ int bedtools_faq(void)
cout
<<
"
\n
"
;
return
0
;
}
void
showHelp
(
const
QuickString
&
subCmd
)
{
if
(
subCmd
==
"intersect"
)
{
intersect_help
();
}
else
if
(
subCmd
==
"map"
)
{
map_help
();
}
else
if
(
subCmd
==
"closest"
)
{
closest_help
();
}
else
if
(
subCmd
==
"merge"
)
{
merge_help
();
}
else
if
(
subCmd
==
"jaccard"
)
{
jaccard_help
();
}
else
if
(
subCmd
==
"subtract"
)
{
subtract_help
();
}
else
if
(
subCmd
==
"sample"
)
{
sample_help
();
}
else
if
(
subCmd
==
"spacing"
)
{
spacing_help
();
}
else
if
(
subCmd
==
"fisher"
)
{
fisher_help
();
}
else
if
(
subCmd
==
"coverage"
)
{
coverage_help
();
}
}
src/closestFile/Makefile
View file @
ed38d473
UTILITIES_DIR
=
../utils/
OBJ_DIR
=
../../obj/
BIN_DIR
=
../../bin/
TOOL_DIR
=
../../src/
# -------------------
# define our includes
...
...
@@ -21,12 +22,15 @@ INCLUDES = -I$(UTILITIES_DIR)/Contexts/ \
-I$(UTILITIES_DIR)/RecordOutputMgr/
\
-I$(UTILITIES_DIR)/NewChromsweep
\
-I$(UTILITIES_DIR)/BinTree
\
-I$(UTILITIES_DIR)/version/
-I$(UTILITIES_DIR)/version/
\
-I$(UTILITIES_DIR)/ToolBase/
\
-I$(TOOL_DIR)/intersectFile/
# ----------------------------------
# define our source and object files
# ----------------------------------
SOURCES
=
closest
Main
.cpp closestFile.cpp closestFile.h
OBJECTS
=
closest
Main
.o closestFile.o
SOURCES
=
closest
Help
.cpp closestFile.cpp closestFile.h
OBJECTS
=
closest
Help
.o closestFile.o
BUILT_OBJECTS
=
$(
patsubst
%,
$(OBJ_DIR)
/%,
$(OBJECTS)
)
all
:
$(BUILT_OBJECTS)
...
...
@@ -39,6 +43,6 @@ $(BUILT_OBJECTS): $(SOURCES)
clean
:
@
echo
"Cleaning up."
@
rm
-f
$(OBJ_DIR)
/closest
Main
.o
$(OBJ_DIR)
/closestFile.o
@
rm
-f
$(OBJ_DIR)
/closest
Help
.o
$(OBJ_DIR)
/closestFile.o
.PHONY
:
clean
src/closestFile/closestFile.cpp
View file @
ed38d473
/*
* newClosestFile.cpp
*
* Created on: Sep 25, 2014
* Author: nek3d
*/
#include
"FileRecordMgr.h"
#include
"RecordOutputMgr.h"
#include
"closestFile.h"
#include
"CloseSweep.h"
ClosestFile
::
ClosestFile
(
ContextClosest
*
context
)
:
_context
(
context
),
_recordOutputMgr
(
NULL
)
{
_recordOutputMgr
=
new
RecordOutputMgr
();
_recordOutputMgr
->
init
(
_context
);
}
ClosestFile
::~
ClosestFile
()
{
delete
_recordOutputMgr
;
}
bool
ClosestFile
::
getClosest
()
{
CloseSweep
sweep
(
_context
);
if
(
!
sweep
.
init
())
{
return
false
;
}
RecordKeyVector
hitSet
;
while
(
sweep
.
next
(
hitSet
))
{
if
(
_context
->
reportDistance
())
{
_recordOutputMgr
->
printClosest
(
hitSet
,
&
(
sweep
.
getDistances
()));
}
else
{
_recordOutputMgr
->
printClosest
(
hitSet
,
NULL
);
}
}
if
(
!
_context
->
hasGenomeFile
())
{
sweep
.
closeOut
(
true
);
}
return
true
;
}
/*
* closestFile.cpp
*
* Created on: Apr 22, 2015
* Author: nek3d
*/
#include
"closestFile.h"
#include
"CloseSweep.h"
ClosestFile
::
ClosestFile
(
ContextClosest
*
context
)
:
IntersectFile
(
context
)
{
}
bool
ClosestFile
::
findNext
(
RecordKeyVector
&
hits
)
{
return
nextSortedFind
(
hits
);
}
void
ClosestFile
::
processHits
(
RecordOutputMgr
*
outputMgr
,
RecordKeyVector
&
hits
)
{
if
(
upCast
(
_context
)
->
reportDistance
())
{
outputMgr
->
printClosest
(
hits
,
&
(
upCastSweep
()
->
getDistances
()));
}
else
{
outputMgr
->
printClosest
(
hits
,
NULL
);
}
}
void
ClosestFile
::
makeSweep
()
{
_sweep
=
new
CloseSweep
(
upCast
(
_context
));
}
src/closestFile/closestFile.h
View file @
ed38d473
/*
* newClosestFile.h
*
* Created on: Sep 25, 2014
* Author: nek3d
*/
#ifndef NEWCLOSESTFILE_H_
#define NEWCLOSESTFILE_H_
#include
"ContextClosest.h"
using
namespace
std
;
class
RecordOutputMgr
;
class
ClosestFile
{
public:
ClosestFile
(
ContextClosest
*
context
);
~
ClosestFile
(
void
);
bool
getClosest
();
private:
ContextClosest
*
_context
;
RecordOutputMgr
*
_recordOutputMgr
;
};
#endif
/* NEWCLOSESTFILE_H_ */
/*
* closestHeader.h
*
* Created on: Apr 22, 2015
* Author: nek3d
*/
#ifndef CLOSESTHEADER_H_
#define CLOSESTHEADER_H_
#include
"intersectFile.h"
#include
"ContextClosest.h"
#include
"CloseSweep.h"
class
ClosestFile
:
public
IntersectFile
{
public:
ClosestFile
(
ContextClosest
*
context
);
bool
findNext
(
RecordKeyVector
&
hits
);
virtual
void
processHits
(
RecordOutputMgr
*
outputMgr
,
RecordKeyVector
&
hits
);
protected:
virtual
ContextClosest
*
upCast
(
ContextBase
*
context
)
{
return
static_cast
<
ContextClosest
*>
(
context
);
}
virtual
CloseSweep
*
upCastSweep
()
{
return
static_cast
<
CloseSweep
*>
(
_sweep
);
}
virtual
void
makeSweep
();
};
#endif
/* CLOSESTHEADER_H_ */
src/closestFile/closest
Main
.cpp
→
src/closestFile/closest
Help
.cpp
View file @
ed38d473
/*
* newClosestMain.cpp
*
* Created on: Sep 25, 2014
* Author: nek3d
*/
using
namespace
std
;
#include
"closestFile.h"
#include
"ContextClosest.h"
// define our program name
#define PROGRAM_NAME "bedtools closest"
void
closest_help
(
void
);
int
closest_main
(
int
argc
,
char
*
argv
[])
{
ContextClosest
*
context
=
new
ContextClosest
();
if
(
!
context
->
parseCmdArgs
(
argc
,
argv
,
1
)
||
context
->
getShowHelp
()
||
!
context
->
isValidState
())
{
if
(
!
context
->
getErrorMsg
().
empty
())
{
cerr
<<
context
->
getErrorMsg
()
<<
endl
;
}
closest_help
();
delete
context
;
return
1
;
}
ClosestFile
*
closestFile
=
new
ClosestFile
(
context
);
bool
retVal
=
closestFile
->
getClosest
();
delete
closestFile
;
delete
context
;
return
retVal
?
0
:
1
;
}
void
closest_help
(
void
)
{
cerr
<<
"
\n
Tool: bedtools closest (aka closestBed)"
<<
endl
;
cerr
<<
"Version: "
<<
VERSION
<<
"
\n
"
;
cerr
<<
"Summary: For each feature in A, finds the closest "
<<
endl
;
cerr
<<
"
\t
feature (upstream or downstream) in B."
<<
endl
<<
endl
;
cerr
<<
"Usage: "
<<
PROGRAM_NAME
<<
" [OPTIONS] -a <bed/gff/vcf> -b <bed/gff/vcf>"
<<
endl
<<
endl
;
cerr
<<
"Options: "
<<
endl
;
cerr
<<
"
\t
-s
\t
"
<<
"Req. same strandedness. That is, find the closest feature in"
<<
endl
;
cerr
<<
"
\t\t
B that overlaps A on the _same_ strand."
<<
endl
;
cerr
<<
"
\t\t
- By default, overlaps are reported without respect to strand."
<<
endl
<<
endl
;
cerr
<<
"
\t
-S
\t
"
<<
"Req. opposite strandedness. That is, find the closest feature"
<<
endl
;
cerr
<<
"
\t\t
in B that overlaps A on the _opposite_ strand."
<<
endl
;
cerr
<<
"
\t\t
- By default, overlaps are reported without respect to strand."
<<
endl
<<
endl
;
cerr
<<
"
\t
-d
\t
"
<<
"In addition to the closest feature in B, "
<<
endl
;
cerr
<<
"
\t\t
report its distance to A as an extra column."
<<
endl
;
cerr
<<
"
\t\t
- The reported distance for overlapping features will be 0."
<<
endl
<<
endl
;
cerr
<<
"
\t
-D
\t
"
<<
"Like -d, report the closest feature in B, and its distance to A"
<<
endl
;
cerr
<<
"
\t\t
as an extra column. Unlike -d, use negative distances to report"
<<
endl
;
cerr
<<
"
\t\t
upstream features."
<<
endl
;
cerr
<<
"
\t\t
The options for defining which orientation is
\"
upstream
\"
are:"
<<
endl
;
cerr
<<
"
\t\t
-
\"
ref
\"
Report distance with respect to the reference genome. "
<<
endl
;
cerr
<<
"
\t\t
B features with a lower (start, stop) are upstream"
<<
endl
;
cerr
<<
"
\t\t
-
\"
a
\"
Report distance with respect to A."
<<
endl
;
cerr
<<
"
\t\t
When A is on the - strand,
\"
upstream
\"
means B has a"
<<
endl
;
cerr
<<
"
\t\t
higher (start,stop)."
<<
endl
;
cerr
<<
"
\t\t
-
\"
b
\"
Report distance with respect to B."
<<
endl
;
cerr
<<
"
\t\t
When B is on the - strand,
\"
upstream
\"
means A has a"
<<
endl
;
cerr
<<
"
\t\t
higher (start,stop)."
<<
endl
<<
endl
;
cerr
<<
"
\t
-io
\t
"
<<
"Ignore features in B that overlap A. That is, we want close,"
<<
endl
;
cerr
<<
"
\t\t
yet not touching features only."
<<
endl
<<
endl
;
cerr
<<
"
\t
-iu
\t
"
<<
"Ignore features in B that are upstream of features in A."
<<
endl
;
cerr
<<
"
\t\t
This option requires -D and follows its orientation"
<<
endl
;
cerr
<<
"
\t\t
rules for determining what is
\"
upstream
\"
."
<<
endl
<<
endl
;
cerr
<<
"
\t
-id
\t
"
<<
"Ignore features in B that are downstream of features in A."
<<
endl
;
cerr
<<
"
\t\t
This option requires -D and follows its orientation"
<<
endl
;
cerr
<<
"
\t\t
rules for determining what is
\"
downstream
\"
."
<<
endl
<<
endl
;
cerr
<<
"
\t
-fu
\t
"
<<
"Choose first from features in B that are upstream of features in A."
<<
endl
;
cerr
<<
"
\t\t
This option requires -D and follows its orientation"
<<
endl
;
cerr
<<
"
\t\t
rules for determining what is
\"
upstream
\"
."
<<
endl
<<
endl
;
cerr
<<
"
\t
-fd
\t
"
<<
"Choose first from features in B that are downstream of features in A."
<<
endl
;
cerr
<<
"
\t\t
This option requires -D and follows its orientation"
<<
endl
;
cerr
<<
"
\t\t
rules for determining what is
\"
downstream
\"
."
<<
endl
<<
endl
;
cerr
<<
"
\t
-t
\t
"
<<
"How ties for closest feature are handled. This occurs when two"
<<
endl
;
cerr
<<
"
\t\t
features in B have exactly the same
\"
closeness
\"
with A."
<<
endl
;
cerr
<<
"
\t\t
By default, all such features in B are reported."
<<
endl
;
cerr
<<
"
\t\t
Here are all the options:"
<<
endl
;
cerr
<<
"
\t\t
-
\"
all
\"
Report all ties (default)."
<<
endl
;
cerr
<<
"
\t\t
-
\"
first
\"
Report the first tie that occurred in the B file."
<<
endl
;
cerr
<<
"
\t\t
-
\"
last
\"
Report the last tie that occurred in the B file."
<<
endl
<<
endl
;
cerr
<<
"
\t
-mdb
\t
"
<<
"How multiple databases are resolved."
<<
endl
;
cerr
<<
"
\t\t
-
\"
each
\"
Report closest records for each database (default)."
<<
endl
;
cerr
<<
"
\t\t
-
\"
all
\"
Report closest records among all databases."
<<
endl
<<
endl
;
cerr
<<
"
\t
-names
\t
"
<<
"When using multiple databases (-b), provide an alias for each that"
<<
endl
;
cerr
<<
"
\t\t
will appear instead of a fileId when also printing the DB record."
<<
endl
<<
endl
;
cerr
<<
"
\t
-filenames"
<<
"
\t
When using multiple databases (-b), show each complete filename"
<<
endl
;
cerr
<<
"
\t\t\t
instead of a fileId when also printing the DB record."
<<
endl
<<
endl
;
cerr
<<
"
\t
-k
\t
"
<<
"Report the k closest hits. Default is 1. If tieMode =
\"
all
\"
, "
<<
endl
;
cerr
<<
"
\t\t
- all ties will still be reported."
<<
endl
<<
endl
;
cerr
<<
"
\t
-N
\t
"
<<
"Require that the query and the closest hit have different names."
<<
endl
;
cerr
<<
"
\t\t
For BED, the 4th column is compared."
<<
endl
<<
endl
;