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
1cdb7084
Commit
1cdb7084
authored
14 years ago
by
Aaron
Browse files
Options
Downloads
Patches
Plain Diff
Added bed12ToBed6
parent
389e806b
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/bed12ToBed6/Makefile
+46
-0
46 additions, 0 deletions
src/bed12ToBed6/Makefile
src/bed12ToBed6/bed12ToBed6.cpp
+155
-0
155 additions, 0 deletions
src/bed12ToBed6/bed12ToBed6.cpp
with
201 additions
and
0 deletions
src/bed12ToBed6/Makefile
0 → 100755
+
46
−
0
View file @
1cdb7084
CXX
=
g++
CXXFLAGS
=
-Wall
-O2
LIBS
=
-lz
UTILITIES_DIR
=
../utils/
OBJ_DIR
=
../../obj/
BIN_DIR
=
../../bin/
# -------------------
# define our includes
# -------------------
INCLUDES
=
-I
$(
UTILITIES_DIR
)
/bedFile/
-I
$(
UTILITIES_DIR
)
/lineFileUtilities/
-I
$(
UTILITIES_DIR
)
/version/
-I
$(
UTILITIES_DIR
)
/gzstream/
# ----------------------------------
# define our source and object files
# ----------------------------------
SOURCES
=
bed12ToBed6.cpp
OBJECTS
=
$(
SOURCES:.cpp
=
.o
)
_EXT_OBJECTS
=
bedFile.o lineFileUtilities.o gzstream.o
EXT_OBJECTS
=
$(
patsubst %,
$(
OBJ_DIR
)
/%,
$(
_EXT_OBJECTS
))
BUILT_OBJECTS
=
$(
patsubst %,
$(
OBJ_DIR
)
/%,
$(
OBJECTS
))
PROGRAM
=
bed12ToBed6
all
:
$(PROGRAM)
.PHONY
:
all
$(PROGRAM)
:
$(BUILT_OBJECTS) $(EXT_OBJECTS)
@
echo
" * linking
$(
PROGRAM
)
"
@$(
CXX
)
$(
LDFLAGS
)
$(
CXXFLAGS
)
-o
$(
BIN_DIR
)
/
$@
$^
$(
LIBS
)
$(BUILT_OBJECTS)
:
$(SOURCES)
@
echo
" * compiling"
$(
*
F
)
.cpp
@$(
CXX
)
-c
-o
$@
$(
*
F
)
.cpp
$(
LDFLAGS
)
$(
CXXFLAGS
)
$(
INCLUDES
)
$(EXT_OBJECTS)
:
@$(
MAKE
)
--no-print-directory
-C
$(
UTILITIES_DIR
)
/lineFileUtilities/
@$(
MAKE
)
--no-print-directory
-C
$(
UTILITIES_DIR
)
/bedFile/
@$(
MAKE
)
--no-print-directory
-C
$(
UTILITIES_DIR
)
/gzstream/
clean
:
@
echo
"Cleaning up."
@
rm
-f
$(
OBJ_DIR
)
/
*
$(
BIN_DIR
)
/
*
.PHONY
:
clean
This diff is collapsed.
Click to expand it.
src/bed12ToBed6/bed12ToBed6.cpp
0 → 100755
+
155
−
0
View file @
1cdb7084
/*****************************************************************************
bed12ToBed6.cpp
(c) 2009 - Aaron Quinlan
Hall Laboratory
Department of Biochemistry and Molecular Genetics
University of Virginia
aaronquinlan@gmail.com
Licenced under the GNU General Public License 2.0+ license.
******************************************************************************/
#include
"lineFileUtilities.h"
#include
"bedFile.h"
#include
"version.h"
#include
<vector>
#include
<iostream>
#include
<fstream>
#include
<stdlib.h>
using
namespace
std
;
// define our program name
#define PROGRAM_NAME "bed12ToBed6"
// define our parameter checking macro
#define PARAMETER_CHECK(param, paramLen, actualLen) (strncmp(argv[i], param, min(actualLen, paramLen))== 0) && (actualLen == paramLen)
// function declarations
void
ShowHelp
(
void
);
void
DetermineBedInput
(
BedFile
*
bed
);
void
ProcessBed
(
istream
&
bedInput
,
BedFile
*
bed
);
int
main
(
int
argc
,
char
*
argv
[])
{
// our configuration variables
bool
showHelp
=
false
;
// input files
string
bedFile
;
bool
haveBed
=
false
;
// check to see if we should print out some help
if
(
argc
<=
1
)
showHelp
=
true
;
for
(
int
i
=
1
;
i
<
argc
;
i
++
)
{
int
parameterLength
=
(
int
)
strlen
(
argv
[
i
]);
if
((
PARAMETER_CHECK
(
"-h"
,
2
,
parameterLength
))
||
(
PARAMETER_CHECK
(
"--help"
,
5
,
parameterLength
)))
{
showHelp
=
true
;
}
}
if
(
showHelp
)
ShowHelp
();
// do some parsing (all of these parameters require 2 strings)
for
(
int
i
=
1
;
i
<
argc
;
i
++
)
{
int
parameterLength
=
(
int
)
strlen
(
argv
[
i
]);
if
(
PARAMETER_CHECK
(
"-i"
,
2
,
parameterLength
))
{
if
((
i
+
1
)
<
argc
)
{
haveBed
=
true
;
bedFile
=
argv
[
i
+
1
];
i
++
;
}
}
else
{
cerr
<<
endl
<<
"*****ERROR: Unrecognized parameter: "
<<
argv
[
i
]
<<
" *****"
<<
endl
<<
endl
;
showHelp
=
true
;
}
}
// make sure we have an input files
if
(
!
haveBed
)
{
cerr
<<
endl
<<
"*****"
<<
endl
<<
"*****ERROR: Need -i (BED) file. "
<<
endl
<<
"*****"
<<
endl
;
showHelp
=
true
;
}
if
(
!
showHelp
)
{
BedFile
*
bed
=
new
BedFile
(
bedFile
);
DetermineBedInput
(
bed
);
}
else
{
ShowHelp
();
}
}
void
ShowHelp
(
void
)
{
cerr
<<
endl
<<
"Program: "
<<
PROGRAM_NAME
<<
" (v"
<<
VERSION
<<
")"
<<
endl
;
cerr
<<
"Author: Aaron Quinlan (aaronquinlan@gmail.com)"
<<
endl
;
cerr
<<
"Summary: Splits BED12 features into discrete BED6 features."
<<
endl
<<
endl
;
cerr
<<
"Usage: "
<<
PROGRAM_NAME
<<
" [OPTIONS] -i <bed>"
<<
endl
<<
endl
;
// end the program here
exit
(
1
);
}
void
DetermineBedInput
(
BedFile
*
bed
)
{
// 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
);
}
// reading from stdin
else
{
ProcessBed
(
cin
,
bed
);
}
}
void
ProcessBed
(
istream
&
bedInput
,
BedFile
*
bed
)
{
// process each BED entry and convert to BAM
BED
bedEntry
,
nullBed
;
int
lineNum
=
0
;
BedLineStatus
bedStatus
;
// open the BED file for reading.
bed
->
Open
();
while
((
bedStatus
=
bed
->
GetNextBed
(
bedEntry
,
lineNum
))
!=
BED_INVALID
)
{
if
(
bedStatus
==
BED_VALID
)
{
bedVector
bedBlocks
;
// vec to store the discrete BED "blocks" from a
splitBedIntoBlocks
(
bedEntry
,
lineNum
,
bedBlocks
);
vector
<
BED
>::
const_iterator
bedItr
=
bedBlocks
.
begin
();
vector
<
BED
>::
const_iterator
bedEnd
=
bedBlocks
.
end
();
for
(;
bedItr
!=
bedEnd
;
++
bedItr
)
{
printf
(
"%s
\t
%d
\t
%d
\t
%s
\t
%s
\t
%s
\n
"
,
bedItr
->
chrom
.
c_str
(),
bedItr
->
start
,
bedItr
->
end
,
bedItr
->
name
.
c_str
(),
bedItr
->
score
.
c_str
(),
bedItr
->
strand
.
c_str
());
}
bedEntry
=
nullBed
;
}
}
// close up
bed
->
Close
();
}
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