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
80820201
Commit
80820201
authored
11 years ago
by
nkindlon
Browse files
Options
Downloads
Patches
Plain Diff
Fixed slop bug when slop factor exceeds MAX signed int.
parent
95098092
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/slopBed/slopBed.cpp
+15
-15
15 additions, 15 deletions
src/slopBed/slopBed.cpp
src/slopBed/slopBed.h
+1
-1
1 addition, 1 deletion
src/slopBed/slopBed.h
test/slop/test-slop.sh
+13
-1
13 additions, 1 deletion
test/slop/test-slop.sh
with
29 additions
and
17 deletions
src/slopBed/slopBed.cpp
+
15
−
15
View file @
80820201
...
@@ -50,12 +50,12 @@ void BedSlop::SlopBed() {
...
@@ -50,12 +50,12 @@ void BedSlop::SlopBed() {
while
(
_bed
->
GetNextBed
(
bedEntry
))
{
while
(
_bed
->
GetNextBed
(
bedEntry
))
{
if
(
_bed
->
_status
==
BED_VALID
)
{
if
(
_bed
->
_status
==
BED_VALID
)
{
if
(
_fractional
==
false
)
{
if
(
_fractional
==
false
)
{
AddSlop
(
bedEntry
,
(
int
)
_leftSlop
,
(
int
)
_rightSlop
);
AddSlop
(
bedEntry
);
}
}
else
{
else
{
int
leftSlop
=
(
int
)
(
_leftSlop
*
bedEntry
.
size
()
)
;
_
leftSlop
=
_leftSlop
*
(
float
)
bedEntry
.
size
();
int
rightSlop
=
(
int
)
(
_rightSlop
*
bedEntry
.
size
()
)
;
_
rightSlop
=
_rightSlop
*
(
float
)
bedEntry
.
size
();
AddSlop
(
bedEntry
,
leftSlop
,
rightSlop
);
AddSlop
(
bedEntry
);
}
}
_bed
->
reportBedNewLine
(
bedEntry
);
_bed
->
reportBedNewLine
(
bedEntry
);
}
}
...
@@ -64,29 +64,29 @@ void BedSlop::SlopBed() {
...
@@ -64,29 +64,29 @@ void BedSlop::SlopBed() {
}
}
void
BedSlop
::
AddSlop
(
BED
&
bed
,
int
leftSlop
,
int
rightSlop
)
{
void
BedSlop
::
AddSlop
(
BED
&
bed
)
{
// special handling if the BED entry is on the negative
// special handling if the BED entry is on the negative
// strand and the user cares about strandedness.
// strand and the user cares about strandedness.
CHRPOS
chromSize
=
_genome
->
getChromSize
(
bed
.
chrom
);
float
chromSize
=
(
float
)
_genome
->
getChromSize
(
bed
.
chrom
);
if
(
(
_forceStrand
)
&&
(
bed
.
strand
==
"-"
)
)
{
if
(
(
_forceStrand
)
&&
(
bed
.
strand
==
"-"
)
)
{
// inspect the start
// inspect the start
if
(
(
static_cast
<
int
>
(
bed
.
start
)
-
rightSlop
)
>
0
)
bed
.
start
-
=
rightSlop
;
float
newStart
=
(
float
)
bed
.
start
-
_
rightSlop
;
else
bed
.
s
tart
=
0
;
bed
.
start
=
(
newStart
>
0
)
?
(
CHRPOS
)
newS
tart
:
0
;
// inspect the
start
// inspect the
end
if
(
(
static_cast
<
int
>
(
bed
.
end
)
+
leftSlop
)
<=
static_cast
<
int
>
(
chromSize
))
bed
.
end
+
=
leftSlop
;
float
newEnd
=
(
float
)
bed
.
end
+
_
leftSlop
;
else
bed
.
end
=
chromSize
;
bed
.
end
=
(
newEnd
<
chromSize
)
?
(
CHRPOS
)
newEnd
:
(
CHRPOS
)
chromSize
;
}
}
else
{
else
{
// inspect the start
// inspect the start
if
(
(
static_cast
<
int
>
(
bed
.
start
)
-
leftSlop
)
>
0
)
bed
.
start
-
=
leftSlop
;
float
newStart
=
(
float
)
bed
.
start
-
_
leftSlop
;
else
bed
.
s
tart
=
0
;
bed
.
start
=
(
newStart
>
0
)
?
(
CHRPOS
)
newS
tart
:
0
;
// inspect the end
// inspect the end
if
(
(
static_cast
<
int
>
(
bed
.
end
)
+
rightSlop
)
<=
static_cast
<
int
>
(
chromSize
))
bed
.
end
+
=
rightSlop
;
float
newEnd
=
(
float
)
bed
.
end
+
_
rightSlop
;
else
bed
.
end
=
chromSize
;
bed
.
end
=
(
newEnd
<
chromSize
)
?
(
CHRPOS
)
newEnd
:
(
CHRPOS
)
chromSize
;
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
src/slopBed/slopBed.h
+
1
−
1
View file @
80820201
...
@@ -57,5 +57,5 @@ private:
...
@@ -57,5 +57,5 @@ private:
void
SlopBed
();
void
SlopBed
();
// method to add requested "slop" to a single BED entry
// method to add requested "slop" to a single BED entry
void
AddSlop
(
BED
&
bed
,
int
leftSlop
,
int
rightSlop
);
void
AddSlop
(
BED
&
bed
);
};
};
This diff is collapsed.
Click to expand it.
test/slop/test-slop.sh
+
13
−
1
View file @
80820201
...
@@ -134,4 +134,16 @@ echo \
...
@@ -134,4 +134,16 @@ echo \
chr1 0 1000 a2 2 -"
>
exp
chr1 0 1000 a2 2 -"
>
exp
$BT
slop
-i
a.bed
-b
2000
-s
-g
tiny.genome
>
obs
$BT
slop
-i
a.bed
-b
2000
-s
-g
tiny.genome
>
obs
check obs exp
check obs exp
rm
obs exp
rm
obs exp
\ No newline at end of file
###########################################################
# test slop factor being larger than a signed int
###########################################################
echo
" slop.t12...
\c
"
echo
\
"chr1 0 1000 a1 1 +
chr1 0 1000 a2 2 -"
>
exp
$BT
slop
-i
a.bed
-b
3000000000
-s
-g
tiny.genome
>
obs
check obs exp
rm
obs exp
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