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
8219b6d9
Commit
8219b6d9
authored
11 years ago
by
nkindlon
Browse files
Options
Downloads
Patches
Plain Diff
Improved help and error msgs in Context
parent
ca4265ec
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/intersectFile/intersectMain.cpp
+2
-2
2 additions, 2 deletions
src/intersectFile/intersectMain.cpp
src/utils/Contexts/Context.cpp
+31
-3
31 additions, 3 deletions
src/utils/Contexts/Context.cpp
src/utils/Contexts/Context.h
+2
-1
2 additions, 1 deletion
src/utils/Contexts/Context.h
with
35 additions
and
6 deletions
src/intersectFile/intersectMain.cpp
+
2
−
2
View file @
8219b6d9
...
...
@@ -23,8 +23,8 @@ void intersect_help(void);
int
intersect_main
(
int
argc
,
char
*
argv
[])
{
Context
*
context
=
new
Context
();
context
->
parseCmdArgs
(
argc
,
argv
,
1
);
if
(
context
->
getShowHelp
()
||
!
context
->
isValidState
())
{
if
(
!
context
->
parseCmdArgs
(
argc
,
argv
,
1
)
||
context
->
getShowHelp
()
||
!
context
->
isValidState
())
{
if
(
!
context
->
getErrorMsg
().
empty
())
{
cerr
<<
context
->
getErrorMsg
()
<<
endl
;
}
...
...
This diff is collapsed.
Click to expand it.
src/utils/Contexts/Context.cpp
+
31
−
3
View file @
8219b6d9
...
...
@@ -44,6 +44,8 @@ Context::Context()
_reportNames
(
false
),
_reportScores
(
false
)
{
_programNames
[
"intersect"
]
=
INTERSECT
;
_validScoreOps
.
insert
(
"sum"
);
_validScoreOps
.
insert
(
"max"
);
_validScoreOps
.
insert
(
"min"
);
...
...
@@ -90,15 +92,17 @@ void Context::openGenomeFile(const BamTools::RefVector &refVector)
_genomeFile
=
new
NewGenomeFile
(
refVector
);
}
void
Context
::
parseCmdArgs
(
int
argc
,
char
**
argv
,
int
skipFirstArgs
)
{
bool
Context
::
parseCmdArgs
(
int
argc
,
char
**
argv
,
int
skipFirstArgs
)
{
_argc
=
argc
;
_argv
=
argv
;
_skipFirstArgs
=
skipFirstArgs
;
if
(
argc
<
2
)
{
setShowHelp
(
true
);
return
;
return
false
;
}
setProgram
(
_programNames
[
argv
[
0
]]);
_argsProcessed
.
resize
(
argc
-
skipFirstArgs
,
false
);
for
(
int
i
=
skipFirstArgs
;
i
<
argc
;
i
++
)
{
...
...
@@ -112,6 +116,10 @@ void Context::parseCmdArgs(int argc, char **argv, int skipFirstArgs) {
i
++
;
markUsed
(
i
-
skipFirstArgs
);
}
else
if
(
strcmp
(
argv
[
i
],
"-g"
)
==
0
)
{
if
(
argc
<=
i
+
1
)
{
_errorMsg
=
"Error: -g option given, but no genome file specified."
;
return
false
;
}
openGenomeFile
(
argv
[
i
+
1
]);
markUsed
(
i
-
skipFirstArgs
);
i
++
;
...
...
@@ -128,6 +136,11 @@ void Context::parseCmdArgs(int argc, char **argv, int skipFirstArgs) {
markUsed
(
i
-
skipFirstArgs
);
}
if
(
strcmp
(
argv
[
i
],
"-a"
)
==
0
)
{
if
(
argc
<=
i
+
1
)
{
_errorMsg
=
"Error: -a option given, but no query file specified."
;
return
false
;
}
addInputFile
(
argv
[
i
+
1
]);
_queryFileIdx
=
getNumInputFiles
()
-
1
;
markUsed
(
i
-
skipFirstArgs
);
...
...
@@ -135,6 +148,10 @@ void Context::parseCmdArgs(int argc, char **argv, int skipFirstArgs) {
markUsed
(
i
-
skipFirstArgs
);
}
else
if
(
strcmp
(
argv
[
i
],
"-abam"
)
==
0
)
{
if
(
argc
<=
i
+
1
)
{
_errorMsg
=
"Error: -abam option given, but no query BAM file specified."
;
return
false
;
}
addInputFile
(
argv
[
i
+
1
]);
_queryFileIdx
=
getNumInputFiles
()
-
1
;
markUsed
(
i
-
skipFirstArgs
);
...
...
@@ -143,6 +160,10 @@ void Context::parseCmdArgs(int argc, char **argv, int skipFirstArgs) {
setInputFileType
(
_queryFileIdx
,
FileRecordTypeChecker
::
BAM_FILE_TYPE
);
}
else
if
(
strcmp
(
argv
[
i
],
"-b"
)
==
0
)
{
if
(
argc
<=
i
+
1
)
{
_errorMsg
=
"Error: -b option given, but no database file specified."
;
return
false
;
}
addInputFile
(
argv
[
i
+
1
]);
_databaseFileIdx
=
getNumInputFiles
()
-
1
;
markUsed
(
i
-
skipFirstArgs
);
...
...
@@ -218,13 +239,20 @@ void Context::parseCmdArgs(int argc, char **argv, int skipFirstArgs) {
markUsed
(
i
-
skipFirstArgs
);
}
}
return
true
;
}
bool
Context
::
isValidState
()
{
if
(
!
Context
::
cmdArgsValid
())
{
if
(
!
cmdArgsValid
())
{
return
false
;
}
if
(
getProgram
()
==
INTERSECT
&&
(
_queryFileIdx
==
-
1
||
_databaseFileIdx
==
-
1
))
{
_errorMsg
=
"Error: Intersect program was not given a query and database file."
;
return
false
;
}
if
(
getAnyHit
()
&&
getNoHit
())
{
_errorMsg
=
"Error: request either -u for anyHit OR -v for noHit, not both."
;
return
false
;
...
...
This diff is collapsed.
Click to expand it.
src/utils/Contexts/Context.h
+
2
−
1
View file @
8219b6d9
...
...
@@ -74,7 +74,7 @@ public:
void
setOutputFileType
(
ContextFileType
fileType
)
{
_outputFileType
=
fileType
;
}
ContextFileType
getOutputFileType
()
const
{
return
_outputFileType
;
}
void
parseCmdArgs
(
int
argc
,
char
**
argv
,
int
skipFirstArgs
);
bool
parseCmdArgs
(
int
argc
,
char
**
argv
,
int
skipFirstArgs
);
//isValidState checks that parameters to context are in an acceptable state.
// If not, the error msg string will be set with a reason why it failed.
...
...
@@ -193,6 +193,7 @@ protected:
ContextRecordType
_recordType
;
};
vector
<
FileEntryType
>
_inputFiles
;
map
<
QuickString
,
PROGRAM_TYPE
>
_programNames
;
bool
_useMergedIntervals
;
NewGenomeFile
*
_genomeFile
;
...
...
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