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
7207d6ea
Commit
7207d6ea
authored
13 years ago
by
Aaron
Browse files
Options
Downloads
Patches
Plain Diff
Added -full to fastaFromBed
parent
7894c168
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/fastaFromBed/fastaFromBed.cpp
+17
-32
17 additions, 32 deletions
src/fastaFromBed/fastaFromBed.cpp
src/fastaFromBed/fastaFromBed.h
+5
-7
5 additions, 7 deletions
src/fastaFromBed/fastaFromBed.h
src/fastaFromBed/fastaFromBedMain.cpp
+13
-12
13 additions, 12 deletions
src/fastaFromBed/fastaFromBedMain.cpp
with
35 additions
and
51 deletions
src/fastaFromBed/fastaFromBed.cpp
+
17
−
32
View file @
7207d6ea
...
...
@@ -13,38 +13,17 @@
#include
"fastaFromBed.h"
Bed2Fa
::
Bed2Fa
(
bool
&
useName
,
string
&
dbFile
,
string
&
bedFile
,
string
&
fastaOutFile
,
bool
&
useFasta
,
bool
&
useStrand
)
{
if
(
useName
)
{
_useName
=
true
;
}
Bed2Fa
::
Bed2Fa
(
const
string
&
dbFile
,
const
string
&
bedFile
,
bool
useFasta
,
bool
useStrand
,
bool
useName
,
bool
useFull
)
{
_dbFile
=
dbFile
;
_bedFile
=
bedFile
;
_fastaOutFile
=
fastaOutFile
;
_useFasta
=
useFasta
;
_useStrand
=
useStrand
;
_useName
=
useName
;
_useFull
=
useFull
;
_bed
=
new
BedFile
(
_bedFile
);
// Figure out what the output file should be.
if
(
fastaOutFile
==
"stdout"
)
{
_faOut
=
&
cout
;
}
else
{
// Make sure we can open the file.
ofstream
fa
(
fastaOutFile
.
c_str
(),
ios
::
out
);
if
(
!
fa
)
{
cerr
<<
"Error: The requested fasta output file ("
<<
fastaOutFile
<<
") could not be opened. Exiting!"
<<
endl
;
exit
(
1
);
}
else
{
fa
.
close
();
_faOut
=
new
ofstream
(
fastaOutFile
.
c_str
(),
ios
::
out
);
}
}
// Extract the requested intervals from the FASTA input file.
ExtractDNA
();
}
...
...
@@ -66,22 +45,28 @@ void Bed2Fa::ReportDNA(const BED &bed, string &dna) {
if
(
!
(
_useName
))
{
if
(
_useFasta
==
true
)
{
if
(
_useStrand
==
true
)
*
_faO
ut
<<
">"
<<
bed
.
chrom
<<
":"
<<
bed
.
start
<<
"-"
<<
bed
.
end
<<
"("
<<
bed
.
strand
<<
")"
<<
endl
<<
dna
<<
endl
;
co
ut
<<
">"
<<
bed
.
chrom
<<
":"
<<
bed
.
start
<<
"-"
<<
bed
.
end
<<
"("
<<
bed
.
strand
<<
")"
<<
endl
<<
dna
<<
endl
;
else
*
_faO
ut
<<
">"
<<
bed
.
chrom
<<
":"
<<
bed
.
start
<<
"-"
<<
bed
.
end
<<
endl
<<
dna
<<
endl
;
co
ut
<<
">"
<<
bed
.
chrom
<<
":"
<<
bed
.
start
<<
"-"
<<
bed
.
end
<<
endl
<<
dna
<<
endl
;
}
else
{
if
(
_useStrand
==
true
)
*
_faOut
<<
bed
.
chrom
<<
":"
<<
bed
.
start
<<
"-"
<<
bed
.
end
<<
"("
<<
bed
.
strand
<<
")"
<<
"
\t
"
<<
dna
<<
endl
;
else
*
_faOut
<<
bed
.
chrom
<<
":"
<<
bed
.
start
<<
"-"
<<
bed
.
end
<<
"
\t
"
<<
dna
<<
endl
;
if
(
_useFull
==
true
)
{
_bed
->
reportBedTab
(
bed
);
cout
<<
dna
<<
endl
;
}
else
{
if
(
_useStrand
==
true
)
cout
<<
bed
.
chrom
<<
":"
<<
bed
.
start
<<
"-"
<<
bed
.
end
<<
"("
<<
bed
.
strand
<<
")"
<<
"
\t
"
<<
dna
<<
endl
;
else
cout
<<
bed
.
chrom
<<
":"
<<
bed
.
start
<<
"-"
<<
bed
.
end
<<
"
\t
"
<<
dna
<<
endl
;
}
}
}
else
{
if
(
_useFasta
==
true
)
*
_faO
ut
<<
">"
<<
bed
.
name
<<
endl
<<
dna
<<
endl
;
co
ut
<<
">"
<<
bed
.
name
<<
endl
<<
dna
<<
endl
;
else
*
_faO
ut
<<
bed
.
name
<<
"
\t
"
<<
dna
<<
endl
;
co
ut
<<
bed
.
name
<<
"
\t
"
<<
dna
<<
endl
;
}
}
...
...
This diff is collapsed.
Click to expand it.
src/fastaFromBed/fastaFromBed.h
+
5
−
7
View file @
7207d6ea
...
...
@@ -29,8 +29,8 @@ class Bed2Fa {
public:
// constructor
Bed2Fa
(
bool
&
useName
,
string
&
dbFile
,
string
&
bedFile
,
string
&
fastaOutFile
,
bool
&
useFasta
,
bool
&
useStrand
);
Bed2Fa
(
const
string
&
dbFile
,
const
string
&
bedFile
,
bool
useFasta
,
bool
useStrand
,
bool
useName
,
bool
useFull
);
// destructor
~
Bed2Fa
(
void
);
...
...
@@ -40,17 +40,15 @@ public:
private:
bool
_useName
;
string
_dbFile
;
string
_bedFile
;
string
_fastaOutFile
;
bool
_useFasta
;
bool
_useStrand
;
bool
_useStrand
;
// should we extract a specific strand?
bool
_useName
;
// should we use the BED name for the FASTA header?
bool
_useFull
;
// should we use the full BED entry for the tabular output?
// instance of a bed file class.
BedFile
*
_bed
;
ostream
*
_faOut
;
};
#endif
This diff is collapsed.
Click to expand it.
src/fastaFromBed/fastaFromBedMain.cpp
+
13
−
12
View file @
7207d6ea
...
...
@@ -39,8 +39,8 @@ int main(int argc, char* argv[]) {
// checks for existence of parameters
bool
haveFastaDb
=
false
;
bool
haveBed
=
false
;
bool
haveFastaOut
=
false
;
bool
useNameOnly
=
false
;
bool
useFullBedEntry
=
false
;
bool
useFasta
=
true
;
bool
useStrand
=
false
;
...
...
@@ -70,13 +70,6 @@ int main(int argc, char* argv[]) {
i
++
;
}
}
else
if
(
PARAMETER_CHECK
(
"-fo"
,
3
,
parameterLength
))
{
if
((
i
+
1
)
<
argc
)
{
haveFastaOut
=
true
;
fastaOutFile
=
argv
[
i
+
1
];
i
++
;
}
}
else
if
(
PARAMETER_CHECK
(
"-bed"
,
4
,
parameterLength
))
{
if
((
i
+
1
)
<
argc
)
{
haveBed
=
true
;
...
...
@@ -87,6 +80,10 @@ int main(int argc, char* argv[]) {
else
if
(
PARAMETER_CHECK
(
"-name"
,
5
,
parameterLength
))
{
useNameOnly
=
true
;
}
else
if
(
PARAMETER_CHECK
(
"-full"
,
5
,
parameterLength
))
{
useFullBedEntry
=
true
;
useFasta
=
false
;
}
else
if
(
PARAMETER_CHECK
(
"-tab"
,
4
,
parameterLength
))
{
useFasta
=
false
;
}
...
...
@@ -99,13 +96,17 @@ int main(int argc, char* argv[]) {
}
}
if
(
!
haveFastaDb
||
!
haveFastaOut
||
!
haveBed
)
{
if
(
!
haveFastaDb
||
!
haveBed
)
{
showHelp
=
true
;
}
if
(
useFullBedEntry
&&
useNameOnly
)
{
cerr
<<
"*****ERROR: Cannot use both -name and -full. Choose one or the other.*****"
<<
endl
<<
endl
;
showHelp
=
true
;
}
if
(
!
showHelp
)
{
Bed2Fa
*
b2f
=
new
Bed2Fa
(
useNameOnly
,
fastaDbFile
,
bedFile
,
fastaOutFile
,
useFasta
,
useStrand
);
Bed2Fa
*
b2f
=
new
Bed2Fa
(
fastaDbFile
,
bedFile
,
useFasta
,
useStrand
,
useNameOnly
,
useFullBedEntry
);
delete
b2f
;
return
0
;
...
...
@@ -123,16 +124,16 @@ void ShowHelp(void) {
cerr
<<
"Summary: Extract DNA sequences into a fasta file based on feature coordinates."
<<
endl
<<
endl
;
cerr
<<
"Usage: "
<<
PROGRAM_NAME
<<
" [OPTIONS] -fi <fasta> -bed <bed/gff/vcf>
-fo <fasta>
"
<<
endl
<<
endl
;
cerr
<<
"Usage: "
<<
PROGRAM_NAME
<<
" [OPTIONS] -fi <fasta> -bed <bed/gff/vcf> "
<<
endl
<<
endl
;
cerr
<<
"Options: "
<<
endl
;
cerr
<<
"
\t
-fi
\t
Input FASTA file"
<<
endl
;
cerr
<<
"
\t
-bed
\t
BED/GFF/VCF file of ranges to extract from -fi"
<<
endl
;
cerr
<<
"
\t
-fo
\t
Output file (can be FASTA or TAB-delimited)"
<<
endl
;
cerr
<<
"
\t
-name
\t
Use the name field for the FASTA header"
<<
endl
;
cerr
<<
"
\t
-tab
\t
Write output in TAB delimited format."
<<
endl
;
cerr
<<
"
\t\t
- Default is FASTA format."
<<
endl
<<
endl
;
cerr
<<
"
\t
-full
\t
Use the full BED entry when using -tab. Default is chr:start-end."
<<
endl
;
cerr
<<
"
\t
-s
\t
Force strandedness. If the feature occupies the antisense strand,"
<<
endl
;
cerr
<<
"
\t\t
the sequence will be reverse complemented."
<<
endl
;
...
...
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