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
5f480366
Commit
5f480366
authored
13 years ago
by
Aaron
Browse files
Options
Downloads
Patches
Plain Diff
chromsweep is a proper tool. Now to make it an iterable class.
parent
4f6253a0
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/chromsweep/chromsweep.cpp
+14
-55
14 additions, 55 deletions
src/chromsweep/chromsweep.cpp
src/chromsweep/chromsweep.h
+1
-16
1 addition, 16 deletions
src/chromsweep/chromsweep.h
src/chromsweep/chromsweepMain.cpp
+2
-6
2 additions, 6 deletions
src/chromsweep/chromsweepMain.cpp
with
17 additions
and
77 deletions
src/chromsweep/chromsweep.cpp
+
14
−
55
View file @
5f480366
...
...
@@ -55,6 +55,10 @@ ChromSweep::ChromSweep(string bedAFile, string bedBFile, bool anyHit,
// prime the results pump.
_qy_lineNum
=
0
;
_db_lineNum
=
0
;
_hits
.
reserve
(
1000
);
_cache
.
reserve
(
1000
);
_bedA
->
Open
();
_bedB
->
Open
();
_qy_status
=
_bedA
->
GetNextBed
(
_curr_qy
,
_qy_lineNum
);
...
...
@@ -125,72 +129,29 @@ void ChromSweep::ChromCheck()
}
else
if
(
_curr_qy
.
chrom
<
_curr_db
.
chrom
)
{
// report hits for the remaining queries on this chrom
BED
tmp_curr_qy
=
_curr_qy
;
while
(
!
_bedA
->
Empty
()
&&
tmp
_curr_qy
.
chrom
==
_
curr_
qy
.
chrom
)
string
curr_chrom
=
_curr_qy
.
chrom
;
while
(
!
_bedA
->
Empty
()
&&
_curr_qy
.
chrom
==
curr_chrom
)
{
ScanCache
();
_results
.
push
(
make_pair
(
tmp
_curr_qy
,
_hits
));
_qy_status
=
_bedA
->
GetNextBed
(
tmp
_curr_qy
,
_qy_lineNum
);
_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
()
&&
tmp
_curr_qy
.
chrom
<
_curr_db
.
chrom
)
while
(
!
_bedA
->
Empty
()
&&
_curr_qy
.
chrom
<
_curr_db
.
chrom
)
{
// hits is empty to reflect the fact that no hits are found in catch-up mode
_results
.
push
(
make_pair
(
tmp
_curr_qy
,
_hits
));
_qy_status
=
_bedA
->
GetNextBed
(
tmp
_curr_qy
,
_qy_lineNum
);
_results
.
push
(
make_pair
(
_curr_qy
,
_hits
));
_qy_status
=
_bedA
->
GetNextBed
(
_curr_qy
,
_qy_lineNum
);
}
_curr_qy
=
tmp_curr_qy
;
_cache
.
clear
();
}
}
//
// void ChromSweep::ChromCheck(BED &curr_qy, BED &curr_db,
// BedLineStatus &qy_status, BedLineStatus &db_status,
// int &qy_lineNum, int &db_lineNum,
// vector<BED> &db_cache, vector<BED> &hits)
// {
// if ((curr_qy.chrom == curr_db.chrom) || (db_status == BED_INVALID) || (qy_status == BED_INVALID)) {
// return;
// }
//
// if (curr_qy.chrom > curr_db.chrom) {
// while (!_bedB->Empty() && curr_db.chrom < curr_qy.chrom)
// {
// db_status = _bedB->GetNextBed(curr_db, db_lineNum);
// }
// db_cache.clear();
// }
// else if (curr_qy.chrom < curr_db.chrom) {
// // report hits for the remaining queries on this chrom
// BED tmp_curr_qy = curr_qy;
// while (!_bedA->Empty() && tmp_curr_qy.chrom == curr_qy.chrom)
// {
// //db_cache = ScanCache(tmp_curr_qy, qy_status, db_cache, hits);
// ScanCache(tmp_curr_qy, qy_status, db_cache, hits);
//
// //ReportHits(tmp_curr_qy, hits);
// _results.push(make_pair(tmp_curr_qy, hits));
// qy_status = _bedA->GetNextBed(tmp_curr_qy, qy_lineNum);
// hits.clear();
// }
// // now fast forward query to catch up to database
// while (!_bedA->Empty() && tmp_curr_qy.chrom < curr_db.chrom)
// {
// // hits is empty to reflect the fact that no hits are found in catch-up mode
// ReportHits(tmp_curr_qy, hits);
// qy_status = _bedA->GetNextBed(tmp_curr_qy, qy_lineNum);
// }
// curr_qy = tmp_curr_qy;
// db_cache.clear();
// }
// }
void
ChromSweep
::
ReportHits
(
const
BED
&
curr_qy
,
const
vector
<
BED
>
&
hits
)
{
_bedA
->
reportBedTab
(
curr_qy
);
cout
<<
hits
.
size
()
<<
endl
;
void
ChromSweep
::
ReportQuery
(
const
BED
&
query
)
{
_bedA
->
reportBedTab
(
query
);
}
...
...
@@ -201,9 +162,7 @@ bool ChromSweep::Next(pair<BED, vector<BED> > &next) {
// 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
)))
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
);
...
...
This diff is collapsed.
Click to expand it.
src/chromsweep/chromsweep.h
+
1
−
16
View file @
5f480366
...
...
@@ -44,7 +44,7 @@ public:
bool
Next
(
pair
<
BED
,
vector
<
BED
>
>
&
next
);
//pair<BED, vector<BED> > GetNextResult(void
);
void
ReportQuery
(
const
BED
&
query
);
private:
...
...
@@ -90,23 +90,8 @@ private:
BedLineStatus
_qy_status
,
_db_status
;
int
_qy_lineNum
,
_db_lineNum
;
//------------------------------------------------
// private methods
//------------------------------------------------
// void ScanCache(const BED &curr_qy, BedLineStatus qy_status, vector<BED> &db_cache, vector<BED> &hits);
//
// void ChromCheck(BED &curr_qy, BED &curr_db,
// BedLineStatus &qy_status, BedLineStatus &db_status,
// int &qy_lineNum, int &db_lineNum,
// vector<BED> &db_cache, vector<BED> &hits);
void
ScanCache
();
void
ChromCheck
();
void
Sweep
();
void
ReportHits
(
const
BED
&
curr_qy
,
const
vector
<
BED
>
&
hits
);
};
#endif
/* CHROMSWEEP_H */
This diff is collapsed.
Click to expand it.
src/chromsweep/chromsweepMain.cpp
+
2
−
6
View file @
5f480366
...
...
@@ -201,13 +201,9 @@ int main(int argc, char* argv[]) {
pair
<
BED
,
vector
<
BED
>
>
hit_set
;
while
(
sweep
->
Next
(
hit_set
))
{
cout
<<
hit_set
.
first
.
chrom
<<
"
\t
"
<<
hit_set
.
first
.
start
<<
"
\t
"
<<
hit_set
.
first
.
end
<<
"
\t
"
<<
hit_set
.
second
.
size
()
<<
"
\n
"
;
sweep
->
ReportQuery
(
hit_set
.
first
);
cout
<<
hit_set
.
second
.
size
()
<<
"
\n
"
;
}
delete
sweep
;
return
0
;
}
...
...
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