Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
bedtools2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
R3
legacy
bedtools2
Commits
ffa852df
Commit
ffa852df
authored
15 years ago
by
Aaron
Browse files
Options
Downloads
Patches
Plain Diff
slopBed now uses the GenomeFile class.
parent
b5e9b670
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/slopBed/Makefile
+4
-3
4 additions, 3 deletions
src/slopBed/Makefile
src/slopBed/slopBed.cpp
+12
-39
12 additions, 39 deletions
src/slopBed/slopBed.cpp
src/slopBed/slopBed.h
+10
-8
10 additions, 8 deletions
src/slopBed/slopBed.h
with
26 additions
and
50 deletions
src/slopBed/Makefile
+
4
−
3
View file @
ffa852df
...
...
@@ -9,14 +9,14 @@ BIN_DIR = ../../bin/
# -------------------
# define our includes
# -------------------
INCLUDES
=
-I
$(
UTILITIES_DIR
)
/bedFile/
-I
$(
UTILITIES_DIR
)
/lineFileUtilities/
-I
$(
UTILITIES_DIR
)
/version/
INCLUDES
=
-I
$(
UTILITIES_DIR
)
/bedFile/
-I
$(
UTILITIES_DIR
)
/genomeFile/
-I
$(
UTILITIES_DIR
)
/lineFileUtilities/
-I
$(
UTILITIES_DIR
)
/version/
# ----------------------------------
# define our source and object files
# ----------------------------------
SOURCES
=
slopBedMain.cpp slopBed.cpp
OBJECTS
=
$(
SOURCES:.cpp
=
.o
)
_EXT_OBJECTS
=
bedFile.o lineFileUtilities.o
_EXT_OBJECTS
=
bedFile.o
genomeFile.o
lineFileUtilities.o
EXT_OBJECTS
=
$(
patsubst %,
$(
OBJ_DIR
)
/%,
$(
_EXT_OBJECTS
))
BUILT_OBJECTS
=
$(
patsubst %,
$(
OBJ_DIR
)
/%,
$(
OBJECTS
))
PROGRAM
=
slopBed
...
...
@@ -37,7 +37,8 @@ $(BUILT_OBJECTS): $(SOURCES)
$(EXT_OBJECTS)
:
@$(
MAKE
)
--no-print-directory
-C
$(
UTILITIES_DIR
)
/lineFileUtilities/
@$(
MAKE
)
--no-print-directory
-C
$(
UTILITIES_DIR
)
/bedFile/
@$(
MAKE
)
--no-print-directory
-C
$(
UTILITIES_DIR
)
/genomeFile/
clean
:
@
echo
"Cleaning up."
@
rm
-f
$(
OBJ_DIR
)
/
*
$(
BIN_DIR
)
/
*
...
...
This diff is collapsed.
Click to expand it.
src/slopBed/slopBed.cpp
+
12
−
39
View file @
ffa852df
...
...
@@ -12,9 +12,7 @@
#include
"lineFileUtilities.h"
#include
"slopBed.h"
/*
Constructor
*/
BedSlop
::
BedSlop
(
string
&
bedFile
,
string
&
genomeFile
,
bool
&
forceStrand
,
int
&
leftSlop
,
int
&
rightSlop
)
{
this
->
bedFile
=
bedFile
;
...
...
@@ -24,14 +22,11 @@ BedSlop::BedSlop(string &bedFile, string &genomeFile, bool &forceStrand, int &le
this
->
leftSlop
=
leftSlop
;
this
->
rightSlop
=
rightSlop
;
this
->
bed
=
new
BedFile
(
bedFile
);
this
->
bed
=
new
BedFile
(
bedFile
);
this
->
genome
=
new
GenomeFile
(
genomeFile
);
}
/*
Destructor
*/
BedSlop
::~
BedSlop
(
void
)
{
}
...
...
@@ -49,7 +44,6 @@ void BedSlop::SlopBed(istream &bedInput) {
lineNum
++
;
BED
bedEntry
;
// used to store the current BED line from the BED file.
if
(
this
->
bed
->
parseLine
(
bedEntry
,
bedFields
,
lineNum
))
{
AddSlop
(
bedEntry
);
bed
->
reportBedNewLine
(
bedEntry
);
...
...
@@ -60,18 +54,18 @@ void BedSlop::SlopBed(istream &bedInput) {
void
BedSlop
::
AddSlop
(
BED
&
bed
)
{
/
*
special handling if the BED entry is on the negative
strand and the user cares about strandedness.
*/
if
((
this
->
forceStrand
)
&&
(
bed
.
strand
==
"-"
))
{
/
/ special handling if the BED entry is on the negative
// strand and the user cares about strandedness.
int
chromSize
=
genome
->
getChromSize
(
bed
.
chrom
);
if
(
(
this
->
forceStrand
)
&&
(
bed
.
strand
==
"-"
)
)
{
// inspect the start
if
((
bed
.
start
-
rightSlop
)
>
0
)
bed
.
start
-=
rightSlop
;
else
bed
.
start
=
0
;
// inspect the start
if
((
bed
.
end
+
leftSlop
)
<=
this
->
chromSize
s
[
bed
.
chrom
]
)
bed
.
end
+=
leftSlop
;
else
bed
.
end
=
this
->
chromSize
s
[
bed
.
chrom
]
;
if
((
bed
.
end
+
leftSlop
)
<=
chromSize
)
bed
.
end
+=
leftSlop
;
else
bed
.
end
=
chromSize
;
}
else
{
// inspect the start
...
...
@@ -79,35 +73,14 @@ void BedSlop::AddSlop(BED &bed) {
else
bed
.
start
=
0
;
// inspect the end
if
((
bed
.
end
+
rightSlop
)
<=
this
->
chromSize
s
[
bed
.
chrom
]
)
bed
.
end
+=
rightSlop
;
else
bed
.
end
=
this
->
chromSize
s
[
bed
.
chrom
]
;
if
((
bed
.
end
+
rightSlop
)
<=
chromSize
)
bed
.
end
+=
rightSlop
;
else
bed
.
end
=
chromSize
;
}
}
void
BedSlop
::
DetermineBedInput
()
{
/* open the GENOME file for reading.
if successful, load each chrom and it's size into
the "chromSize" map. also compute the total size of the genome
and store in "genomeSize"
*/
ifstream
genome
(
this
->
genomeFile
.
c_str
(),
ios
::
in
);
if
(
!
genome
)
{
cerr
<<
"Error: The requested genome file ("
<<
this
->
genomeFile
<<
") could not be opened. Exiting!"
<<
endl
;
exit
(
1
);
}
else
{
string
chrom
;
unsigned
int
size
;
while
(
genome
>>
chrom
>>
size
)
{
if
(
chrom
.
size
()
>
0
&&
size
>
0
)
{
this
->
chromSizes
[
chrom
]
=
size
;
}
}
}
if
(
this
->
bedFile
!=
"stdin"
)
{
// process a file
ifstream
beds
(
this
->
bedFile
.
c_str
(),
ios
::
in
);
if
(
!
beds
)
{
...
...
This diff is collapsed.
Click to expand it.
src/slopBed/slopBed.h
+
10
−
8
View file @
ffa852df
#include
"bedFile.h"
#include
<vector>
#include
<iostream>
#include
<fstream>
#include
<map>
#include
<cstdlib>
/*****************************************************************************
slopBed.h
...
...
@@ -15,6 +9,15 @@
Licenced under the GNU General Public License 2.0+ license.
******************************************************************************/
#include
"bedFile.h"
#include
"genomeFile.h"
#include
<vector>
#include
<iostream>
#include
<fstream>
#include
<map>
#include
<cstdlib>
#include
<ctime>
using
namespace
std
;
...
...
@@ -49,6 +52,5 @@ private:
int
rightSlop
;
BedFile
*
bed
;
map
<
string
,
int
,
less
<
string
>
>
chromSizes
;
GenomeFile
*
genome
;
};
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment