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
0cca2731
Commit
0cca2731
authored
13 years ago
by
Aaron
Browse files
Options
Downloads
Patches
Plain Diff
Added -scores option to tagBam
parent
47771289
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/tagBam/tagBam.cpp
+14
-3
14 additions, 3 deletions
src/tagBam/tagBam.cpp
src/tagBam/tagBam.h
+5
-2
5 additions, 2 deletions
src/tagBam/tagBam.h
src/tagBam/tagBamMain.cpp
+23
-11
23 additions, 11 deletions
src/tagBam/tagBamMain.cpp
with
42 additions
and
16 deletions
src/tagBam/tagBam.cpp
+
14
−
3
View file @
0cca2731
...
...
@@ -15,13 +15,14 @@
// build
TagBam
::
TagBam
(
const
string
&
bamFile
,
const
vector
<
string
>
&
annoFileNames
,
const
vector
<
string
>
&
annoLables
,
const
string
&
tag
,
bool
useNames
,
bool
sameStrand
,
bool
diffStrand
,
float
overlapFraction
)
:
bool
useNames
,
bool
useScores
,
bool
sameStrand
,
bool
diffStrand
,
float
overlapFraction
)
:
_bamFile
(
bamFile
),
_annoFileNames
(
annoFileNames
),
_annoLabels
(
annoLables
),
_tag
(
tag
),
_useNames
(
useNames
),
_useScores
(
useScores
),
_sameStrand
(
sameStrand
),
_diffStrand
(
diffStrand
),
_overlapFraction
(
overlapFraction
)
...
...
@@ -92,15 +93,25 @@ void TagBam::Tag() {
// grab the current annotation file.
BedFile
*
anno
=
_annoFiles
[
i
];
if
(
!
_useNames
)
{
if
(
!
_useNames
&&
!
_useScores
)
{
// add the label for this annotation file to tag if there is overlap
if
(
anno
->
FindOneOrMoreOverlapsPerBin
(
a
.
chrom
,
a
.
start
,
a
.
end
,
a
.
strand
,
_sameStrand
,
_diffStrand
,
_overlapFraction
))
{
annotations
<<
_annoLabels
[
i
]
<<
";"
;
}
}
// use the score field
else
if
(
!
_useNames
&&
_useScores
)
{
anno
->
FindOverlapsPerBin
(
a
.
chrom
,
a
.
start
,
a
.
end
,
a
.
strand
,
hits
,
_sameStrand
,
_diffStrand
);
for
(
size_t
i
=
0
;
i
<
hits
.
size
();
++
i
)
{
annotations
<<
hits
[
i
].
score
;
if
(
i
<
hits
.
size
()
-
1
)
annotations
<<
","
;
}
if
(
hits
.
size
()
>
0
)
annotations
<<
";"
;
hits
.
clear
();
}
// use the name field from the annotation files to populate tag
else
{
else
if
(
_useNames
&&
!
_useScores
)
{
anno
->
FindOverlapsPerBin
(
a
.
chrom
,
a
.
start
,
a
.
end
,
a
.
strand
,
hits
,
_sameStrand
,
_diffStrand
);
for
(
size_t
i
=
0
;
i
<
hits
.
size
();
++
i
)
{
annotations
<<
hits
[
i
].
name
;
...
...
This diff is collapsed.
Click to expand it.
src/tagBam/tagBam.h
+
5
−
2
View file @
0cca2731
...
...
@@ -40,8 +40,9 @@ public:
// constructor
TagBam
(
const
string
&
bamFile
,
const
vector
<
string
>
&
annoFileNames
,
const
vector
<
string
>
&
annoLabels
,
const
string
&
tag
,
bool
useNames
,
bool
sameStrand
,
bool
diffStrand
,
float
overlapFraction
);
const
vector
<
string
>
&
annoLabels
,
const
string
&
tag
,
bool
useNames
,
bool
useScores
,
bool
sameStrand
,
bool
diffStrand
,
float
overlapFraction
);
// destructor
~
TagBam
(
void
);
...
...
@@ -55,6 +56,7 @@ private:
string
_bamFile
;
vector
<
string
>
_annoFileNames
;
vector
<
string
>
_annoLabels
;
string
_tag
;
// instance of a bed file class.
...
...
@@ -63,6 +65,7 @@ private:
// should we use the name field from the annotation files?
bool
_useNames
;
bool
_useScores
;
// do we care about strandedness when tagging?
bool
_sameStrand
;
...
...
This diff is collapsed.
Click to expand it.
src/tagBam/tagBamMain.cpp
+
23
−
11
View file @
0cca2731
...
...
@@ -34,14 +34,16 @@ int main(int argc, char* argv[]) {
string
tag
=
"YB"
;
// parm flags
bool
haveTag
=
false
;
bool
haveFraction
=
false
;
bool
useNames
=
false
;
bool
sameStrand
=
false
;
bool
diffStrand
=
false
;
bool
haveBam
=
false
;
bool
haveFiles
=
false
;
bool
haveLabels
=
false
;
bool
haveTag
=
false
;
bool
haveFraction
=
false
;
bool
useNames
=
false
;
bool
useScores
=
false
;
bool
sameStrand
=
false
;
bool
diffStrand
=
false
;
bool
haveBam
=
false
;
bool
haveFiles
=
false
;
bool
haveLabels
=
false
;
// list of annotation files / names
vector
<
string
>
inputFiles
;
...
...
@@ -104,6 +106,9 @@ int main(int argc, char* argv[]) {
else
if
(
PARAMETER_CHECK
(
"-names"
,
6
,
parameterLength
))
{
useNames
=
true
;
}
else
if
(
PARAMETER_CHECK
(
"-scores"
,
7
,
parameterLength
))
{
useScores
=
true
;
}
else
if
(
PARAMETER_CHECK
(
"-s"
,
2
,
parameterLength
))
{
sameStrand
=
true
;
}
...
...
@@ -135,8 +140,8 @@ int main(int argc, char* argv[]) {
cerr
<<
endl
<<
"*****"
<<
endl
<<
"*****ERROR: Need -i, -files"
<<
endl
<<
"*****"
<<
endl
;
showHelp
=
true
;
}
if
(
!
useNames
&&
!
haveLabels
)
{
cerr
<<
endl
<<
"*****"
<<
endl
<<
"*****ERROR: Need -labels or -names"
<<
endl
<<
"*****"
<<
endl
;
if
(
!
useNames
&&
!
haveLabels
&&
!
useScores
)
{
cerr
<<
endl
<<
"*****"
<<
endl
<<
"*****ERROR: Need -labels or -names
or -scores
"
<<
endl
<<
"*****"
<<
endl
;
showHelp
=
true
;
}
if
(
sameStrand
&&
diffStrand
)
{
...
...
@@ -147,13 +152,17 @@ int main(int argc, char* argv[]) {
cerr
<<
endl
<<
"*****"
<<
endl
<<
"*****ERROR: Use -labels or -names, not both. "
<<
endl
<<
"*****"
<<
endl
;
showHelp
=
true
;
}
if
(
useScores
&&
useNames
)
{
cerr
<<
endl
<<
"*****"
<<
endl
<<
"*****ERROR: Use -scores or -names, not both. "
<<
endl
<<
"*****"
<<
endl
;
showHelp
=
true
;
}
if
(
haveTag
&&
tag
.
size
()
>
2
)
{
cerr
<<
endl
<<
"*****"
<<
endl
<<
"*****ERROR: Custom tags should be at most two characters per the SAM specification. "
<<
endl
<<
"*****"
<<
endl
;
showHelp
=
true
;
}
if
(
!
showHelp
)
{
TagBam
*
ba
=
new
TagBam
(
bamFile
,
inputFiles
,
inputLabels
,
tag
,
useNames
,
sameStrand
,
diffStrand
,
overlapFraction
);
TagBam
*
ba
=
new
TagBam
(
bamFile
,
inputFiles
,
inputLabels
,
tag
,
useNames
,
useScores
,
sameStrand
,
diffStrand
,
overlapFraction
);
ba
->
Tag
();
delete
ba
;
return
0
;
...
...
@@ -191,6 +200,9 @@ void ShowHelp(void) {
cerr
<<
"
\t
-names
\t
"
<<
"Use the name field from the annotation files to populate tags."
<<
endl
;
cerr
<<
"
\t\t
By default, the -labels values are used."
<<
endl
<<
endl
;
cerr
<<
"
\t
-scores
\t
"
<<
"A list of 1-based columns for each annotation file"
<<
endl
;
cerr
<<
"
\t\t
in which a color can be found."
<<
endl
<<
endl
;
exit
(
1
);
...
...
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