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
5f8020b4
Commit
5f8020b4
authored
13 years ago
by
Aaron
Browse files
Options
Downloads
Patches
Plain Diff
chromsweep no longer overloads results p_q on chrom change.
parent
d2fdf4e7
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/utils/chromsweep/chromsweep.cpp
+35
-36
35 additions, 36 deletions
src/utils/chromsweep/chromsweep.cpp
src/utils/chromsweep/chromsweep.h
+2
-1
2 additions, 1 deletion
src/utils/chromsweep/chromsweep.h
with
37 additions
and
37 deletions
src/utils/chromsweep/chromsweep.cpp
+
35
−
36
View file @
5f8020b4
...
...
@@ -70,7 +70,7 @@ ChromSweep::~ChromSweep(void) {
void
ChromSweep
::
ScanCache
()
{
if
(
_qy_status
!=
BED_INVALID
)
{
vector
<
BED
>::
iterator
c
=
_cache
.
begin
();
vector
<
BED
>::
iterator
c
=
_cache
.
begin
();
while
(
c
!=
_cache
.
end
())
{
if
((
_curr_qy
.
chrom
==
c
->
chrom
)
&&
!
(
after
(
_curr_qy
,
*
c
)))
{
...
...
@@ -87,43 +87,40 @@ void ChromSweep::ScanCache() {
}
void
ChromSweep
::
ChromCh
eck
()
bool
ChromSweep
::
ChromCh
ange
()
{
// the files are on the chrom
// the files are on the
same
chrom
if
((
_curr_qy
.
chrom
==
_curr_db
.
chrom
)
||
(
_db_status
==
BED_INVALID
)
||
(
_qy_status
==
BED_INVALID
))
{
return
;
return
false
;
}
// the query is ahead of the database.
// fast-forward the database to catch-up.
if
(
_curr_qy
.
chrom
>
_curr_db
.
chrom
)
{
// the query is ahead of the database. fast-forward the database to catch-up.
else
if
(
_curr_qy
.
chrom
>
_curr_db
.
chrom
)
{
while
(
!
_bedB
->
Empty
()
&&
_curr_db
.
chrom
<
_curr_qy
.
chrom
)
{
_db_status
=
_bedB
->
GetNextBed
(
_curr_db
,
_db_lineNum
);
}
_cache
.
clear
();
return
false
;
}
// the database is ahead of the query.
// 1. scan the cache for remaining hits on the query's current chrom.
// 2. fast-forward until we catch up and report 0 hits until we do.
else
if
(
_curr_qy
.
chrom
<
_curr_db
.
chrom
)
{
// report hits for the remaining queries on this chrom
string
curr_chrom
=
_curr_qy
.
chrom
;
while
(
!
_bedA
->
Empty
()
&&
_curr_qy
.
chrom
==
curr_chrom
)
else
{
// 1. scan the cache for remaining hits on the query's current chrom.
if
(
_curr_qy
.
chrom
==
_curr_chrom
)
{
ScanCache
();
_results
.
push
(
make_pair
(
_curr_qy
,
_hits
));
_qy_status
=
_bedA
->
GetNextBed
(
_curr_qy
,
_qy_lineNum
);
_hits
.
clear
();
}
//
now
fast
forward
query to
catch up
to database
while
(
!
_bedA
->
Empty
()
&&
_curr_qy
.
chrom
<
_curr_db
.
chrom
)
//
2.
fast
-
forward
until we
catch up
and report 0 hits until we do.
else
if
(
_curr_qy
.
chrom
<
_curr_db
.
chrom
)
{
//
hits
is empty to reflect the fact that no hits are found in catch-up mode
_
hits
.
clear
();
_results
.
push
(
make_pair
(
_curr_qy
,
_hits
));
_
qy_status
=
_bedA
->
GetNextBed
(
_curr_qy
,
_qy_lineNum
);
_
cache
.
clear
(
);
}
_cache
.
clear
();
_qy_status
=
_bedA
->
GetNextBed
(
_curr_qy
,
_qy_lineNum
);
_curr_chrom
=
_curr_qy
.
chrom
;
return
true
;
}
}
...
...
@@ -131,24 +128,26 @@ void ChromSweep::ChromCheck()
bool
ChromSweep
::
Next
(
pair
<
BED
,
vector
<
BED
>
>
&
next
)
{
if
(
!
_bedA
->
Empty
())
{
// have we changed chromosomes?
ChromCheck
();
// scan the database cache for hits
ScanCache
();
// advance the db until we are ahead of the query. update hits and cache as necessary
while
(
!
_bedB
->
Empty
()
&&
_curr_qy
.
chrom
==
_curr_db
.
chrom
&&
!
(
after
(
_curr_db
,
_curr_qy
)))
{
if
(
overlaps
(
_curr_qy
.
start
,
_curr_qy
.
end
,
_curr_db
.
start
,
_curr_db
.
end
)
>
0
)
{
_hits
.
push_back
(
_curr_db
);
if
(
ChromChange
()
==
false
)
{
// scan the database cache for hits
ScanCache
();
// advance the db until we are ahead of the query. update hits and cache as necessary
while
(
!
_bedB
->
Empty
()
&&
_curr_qy
.
chrom
==
_curr_db
.
chrom
&&
!
(
after
(
_curr_db
,
_curr_qy
)))
{
if
(
overlaps
(
_curr_qy
.
start
,
_curr_qy
.
end
,
_curr_db
.
start
,
_curr_db
.
end
)
>
0
)
{
_hits
.
push_back
(
_curr_db
);
}
_cache
.
push_back
(
_curr_db
);
_db_status
=
_bedB
->
GetNextBed
(
_curr_db
,
_db_lineNum
);
}
_cache
.
push_back
(
_curr_db
);
_db_status
=
_bedB
->
GetNextBed
(
_curr_db
,
_db_lineNum
);
// add the hits for this query to the pump
_results
.
push
(
make_pair
(
_curr_qy
,
_hits
));
// reset for the next query
_hits
.
clear
();
_curr_qy
=
_nullBed
;
_qy_status
=
_bedA
->
GetNextBed
(
_curr_qy
,
_qy_lineNum
);
_curr_chrom
=
_curr_qy
.
chrom
;
}
// add the hits for this query to the pump
_results
.
push
(
make_pair
(
_curr_qy
,
_hits
));
// reset for the next query
_hits
.
clear
();
_curr_qy
=
_nullBed
;
_qy_status
=
_bedA
->
GetNextBed
(
_curr_qy
,
_qy_lineNum
);
}
// report the next set if hits if there are still overlaps in the pump
if
(
!
_results
.
empty
())
{
...
...
This diff is collapsed.
Click to expand it.
src/utils/chromsweep/chromsweep.h
+
2
−
1
View file @
5f8020b4
...
...
@@ -67,6 +67,7 @@ private:
// variables for the current query and db entries.
BED
_curr_qy
,
_curr_db
;
string
_curr_chrom
;
BedLineStatus
_qy_status
,
_db_status
;
int
_qy_lineNum
,
_db_lineNum
;
...
...
@@ -74,7 +75,7 @@ private:
private:
void
ScanCache
();
void
ChromCh
eck
();
bool
ChromCh
ange
();
};
#endif
/* CHROMSWEEP_H */
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