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
1cfd5315
Commit
1cfd5315
authored
14 years ago
by
Aaron
Browse files
Options
Downloads
Patches
Plain Diff
Added -ubam support to intersectBed and bedToBam.
parent
8c37692f
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/bedToBam/bedToBam.cpp
+10
-25
10 additions, 25 deletions
src/bedToBam/bedToBam.cpp
src/intersectBed/intersectMain.cpp
+3
-1
3 additions, 1 deletion
src/intersectBed/intersectMain.cpp
src/utils/bedFile/bedFile.cpp
+2
-1
2 additions, 1 deletion
src/utils/bedFile/bedFile.cpp
with
15 additions
and
27 deletions
src/bedToBam/bedToBam.cpp
+
10
−
25
View file @
1cfd5315
/*****************************************************************************
b
am
ToB
ed
.cpp
b
ed
ToB
am
.cpp
(c) 2009 - Aaron Quinlan
Hall Laboratory
...
...
@@ -36,8 +36,7 @@ using namespace std;
// function declarations
void
ShowHelp
(
void
);
void
DetermineBedInput
(
BedFile
*
bed
,
GenomeFile
*
genome
,
bool
isBED12
,
int
mapQual
);
void
ProcessBed
(
istream
&
bedInput
,
BedFile
*
bed
,
GenomeFile
*
genome
,
bool
isBED12
,
int
mapQual
);
void
ProcessBed
(
istream
&
bedInput
,
BedFile
*
bed
,
GenomeFile
*
genome
,
bool
isBED12
,
int
mapQual
,
bool
uncompressedBam
);
void
ConvertBedToBam
(
const
BED
&
bed
,
BamAlignment
&
bam
,
map
<
string
,
int
>
&
chromToId
,
bool
isBED12
,
int
mapQual
,
int
lineNum
);
void
MakeBamHeader
(
const
string
&
genomeFile
,
RefVector
&
refs
,
string
&
header
,
map
<
string
,
int
>
&
chromToInt
);
int
reg2bin
(
int
beg
,
int
end
);
...
...
@@ -59,6 +58,7 @@ int main(int argc, char* argv[]) {
bool
haveGenome
=
false
;
bool
haveMapQual
=
false
;
bool
isBED12
=
false
;
bool
uncompressedBam
=
false
;
for
(
int
i
=
1
;
i
<
argc
;
i
++
)
{
int
parameterLength
=
(
int
)
strlen
(
argv
[
i
]);
...
...
@@ -98,6 +98,9 @@ int main(int argc, char* argv[]) {
}
else
if
(
PARAMETER_CHECK
(
"-bed12"
,
6
,
parameterLength
))
{
isBED12
=
true
;
}
else
if
(
PARAMETER_CHECK
(
"-ubam"
,
5
,
parameterLength
))
{
uncompressedBam
=
true
;
}
else
{
cerr
<<
endl
<<
"*****ERROR: Unrecognized parameter: "
<<
argv
[
i
]
<<
" *****"
<<
endl
<<
endl
;
...
...
@@ -124,7 +127,7 @@ int main(int argc, char* argv[]) {
BedFile
*
bed
=
new
BedFile
(
bedFile
);
GenomeFile
*
genome
=
new
GenomeFile
(
genomeFile
);
DetermineBedInput
(
bed
,
genome
,
isBED12
,
mapQual
);
ProcessBed
(
cin
,
bed
,
genome
,
isBED12
,
mapQual
,
uncompressedBam
);
}
else
{
ShowHelp
();
...
...
@@ -150,6 +153,7 @@ void ShowHelp(void) {
cerr
<<
"
\t
-bed12
\t
"
<<
"The BED file is in BED12 format. The BAM CIGAR"
<<
endl
;
cerr
<<
"
\t\t
string will reflect BED
\"
blocks
\"
."
<<
endl
<<
endl
;
cerr
<<
"
\t
-ubam
\t
"
<<
"Write uncompressed BAM output. Default is to write compressed BAM."
<<
endl
<<
endl
;
cerr
<<
"Notes: "
<<
endl
;
cerr
<<
"
\t
(1) BED files must be at least BED4 to be amenable to BAM (needs name field)."
<<
endl
<<
endl
;
...
...
@@ -160,26 +164,7 @@ void ShowHelp(void) {
}
void
DetermineBedInput
(
BedFile
*
bed
,
GenomeFile
*
genome
,
bool
isBED12
,
int
mapQual
)
{
// dealing with a proper file
if
(
bed
->
bedFile
!=
"stdin"
)
{
ifstream
bedStream
(
bed
->
bedFile
.
c_str
(),
ios
::
in
);
if
(
!
bedStream
)
{
cerr
<<
"Error: The requested bed file ("
<<
bed
->
bedFile
<<
") could not be opened. Exiting!"
<<
endl
;
exit
(
1
);
}
ProcessBed
(
bedStream
,
bed
,
genome
,
isBED12
,
mapQual
);
}
// reading from stdin
else
{
ProcessBed
(
cin
,
bed
,
genome
,
isBED12
,
mapQual
);
}
}
void
ProcessBed
(
istream
&
bedInput
,
BedFile
*
bed
,
GenomeFile
*
genome
,
bool
isBED12
,
int
mapQual
)
{
void
ProcessBed
(
istream
&
bedInput
,
BedFile
*
bed
,
GenomeFile
*
genome
,
bool
isBED12
,
int
mapQual
,
bool
uncompressedBam
)
{
BamWriter
*
writer
=
new
BamWriter
();
...
...
@@ -190,7 +175,7 @@ void ProcessBed(istream &bedInput, BedFile *bed, GenomeFile *genome, bool isBED1
MakeBamHeader
(
genome
->
getGenomeFileName
(),
refs
,
bamHeader
,
chromToId
);
// open a BAM and add the reference headers to the BAM file
writer
->
Open
(
"stdout"
,
bamHeader
,
refs
);
writer
->
Open
(
"stdout"
,
bamHeader
,
refs
,
uncompressedBam
);
// process each BED entry and convert to BAM
...
...
This diff is collapsed.
Click to expand it.
src/intersectBed/intersectMain.cpp
+
3
−
1
View file @
1cfd5315
...
...
@@ -222,7 +222,9 @@ void ShowHelp(void) {
cerr
<<
"Options: "
<<
endl
;
cerr
<<
"
\t
-abam
\t
"
<<
"The A input file is in BAM format. Output will be BAM as well."
<<
endl
<<
endl
;
cerr
<<
"
\t
-ubam
\t
"
<<
"Write uncompressed BAM output. Default is to write compressed BAM."
<<
endl
<<
endl
;
cerr
<<
"
\t
-bed
\t
"
<<
"When using BAM input (-abam), write output as BED. The default"
<<
endl
;
cerr
<<
"
\t\t
is to write output in BAM when using -abam."
<<
endl
<<
endl
;
...
...
This diff is collapsed.
Click to expand it.
src/utils/bedFile/bedFile.cpp
+
2
−
1
View file @
1cfd5315
...
...
@@ -197,7 +197,8 @@ BedLineStatus BedFile::GetNextBed(BED &bed, int &lineNum) {
}
void
BedFile
::
FindOverlapsPerBin
(
string
chrom
,
CHRPOS
start
,
CHRPOS
end
,
string
strand
,
vector
<
BED
>
&
hits
,
bool
forceStrand
)
{
void
BedFile
::
FindOverlapsPerBin
(
string
chrom
,
CHRPOS
start
,
CHRPOS
end
,
string
strand
,
vector
<
BED
>
&
hits
,
bool
forceStrand
)
{
BIN
startBin
,
endBin
;
startBin
=
(
start
>>
_binFirstShift
);
...
...
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