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
ebf9a72c
Commit
ebf9a72c
authored
11 years ago
by
arq5x
Browse files
Options
Downloads
Patches
Plain Diff
add a Context for Map tool.
parent
a45f98c0
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/utils/Contexts/ContextMap.cpp
+121
-0
121 additions, 0 deletions
src/utils/Contexts/ContextMap.cpp
src/utils/Contexts/ContextMap.h
+39
-0
39 additions, 0 deletions
src/utils/Contexts/ContextMap.h
with
160 additions
and
0 deletions
src/utils/Contexts/ContextMap.cpp
0 → 100644
+
121
−
0
View file @
ebf9a72c
/*
* ContextMap.cpp
*
* Created on: Jan 6, 2014
* Author: arq5x
*/
#include
"ContextMap.h"
ContextMap
::
ContextMap
()
{
// map requires sorted input
setSortedInput
(
true
);
setLeftJoin
(
true
);
// default to BED score column
setColumn
(
5
);
// default to "sum"
setColumnOperation
(
"sum"
);
// default to "." as a NULL value
setNullValue
(
'.'
);
}
ContextMap
::~
ContextMap
()
{
}
bool
ContextMap
::
parseCmdArgs
(
int
argc
,
char
**
argv
,
int
skipFirstArgs
)
{
_argc
=
argc
;
_argv
=
argv
;
_skipFirstArgs
=
skipFirstArgs
;
if
(
_argc
<
2
)
{
setShowHelp
(
true
);
return
false
;
}
setProgram
(
_programNames
[
argv
[
0
]]);
_argsProcessed
.
resize
(
_argc
-
_skipFirstArgs
,
false
);
for
(
_i
=
_skipFirstArgs
;
_i
<
argc
;
_i
++
)
{
if
(
isUsed
(
_i
-
_skipFirstArgs
))
{
continue
;
}
else
if
(
strcmp
(
_argv
[
_i
],
"-o"
)
==
0
)
{
if
(
!
handle_o
())
return
false
;
}
else
if
(
strcmp
(
_argv
[
_i
],
"-c"
)
==
0
)
{
if
(
!
handle_c
())
return
false
;
}
else
if
(
strcmp
(
_argv
[
_i
],
"-null"
)
==
0
)
{
if
(
!
handle_null
())
return
false
;
}
}
return
ContextIntersect
::
parseCmdArgs
(
argc
,
argv
,
_skipFirstArgs
);
}
bool
ContextMap
::
isValidState
()
{
if
(
!
cmdArgsValid
())
{
return
false
;
}
ContextIntersect
::
isValidState
();
if
(
getDatabaseFileType
()
==
FileRecordTypeChecker
::
BAM_FILE_TYPE
)
{
//throw Error
cerr
<<
endl
<<
"*****"
<<
endl
<<
"***** ERROR: BAM database file not currently supported for the map tool."
<<
endl
;
exit
(
1
);
}
// TODO
// enforce any specific checks for Map.
return
ContextIntersect
::
isValidState
();
}
// for map, -c is the column upon which to operate
bool
ContextMap
::
handle_c
()
{
if
((
_i
+
1
)
<
_argc
)
{
setColumn
(
atoi
(
_argv
[
_i
+
1
]));
markUsed
(
_i
-
_skipFirstArgs
);
_i
++
;
markUsed
(
_i
-
_skipFirstArgs
);
}
return
true
;
}
// for map, -o is the operation to apply to the column (-c)
bool
ContextMap
::
handle_o
()
{
if
((
_i
+
1
)
<
_argc
)
{
setColumnOperation
(
_argv
[
_i
+
1
]);
markUsed
(
_i
-
_skipFirstArgs
);
_i
++
;
markUsed
(
_i
-
_skipFirstArgs
);
}
return
true
;
}
// for map, -null is a NULL vakue assigned
// when no overlaps are detected.
bool
ContextMap
::
handle_null
()
{
if
((
_i
+
1
)
<
_argc
)
{
setNullValue
(
_argv
[
_i
+
1
]);
markUsed
(
_i
-
_skipFirstArgs
);
_i
++
;
markUsed
(
_i
-
_skipFirstArgs
);
}
return
true
;
}
This diff is collapsed.
Click to expand it.
src/utils/Contexts/ContextMap.h
0 → 100644
+
39
−
0
View file @
ebf9a72c
/*
* ContextMap.h
*
* Created on: Jan 7, 2014
* Author: arq5x
*/
#ifndef CONTEXTMAP_H_
#define CONTEXTMAP_H_
#include
"ContextIntersect.h"
class
ContextMap
:
public
ContextIntersect
{
public:
ContextMap
();
virtual
~
ContextMap
();
virtual
bool
isValidState
();
virtual
bool
parseCmdArgs
(
int
argc
,
char
**
argv
,
int
skipFirstArgs
);
int
getColumn
()
const
{
return
_column
;
}
void
setColumn
(
int
column
)
{
_column
=
column
;
}
const
QuickString
&
getColumnOperation
()
const
{
return
_columnOperation
;
}
void
setColumnOperation
(
const
QuickString
&
operation
)
{
_columnOperation
=
operation
;
}
const
QuickString
&
getNullValue
()
const
{
return
_nullValue
;
}
void
setNullValue
(
const
QuickString
&
nullValue
)
{
_nullValue
=
nullValue
;
}
virtual
bool
hasIntersectMethods
()
const
{
return
true
;
}
private
:
virtual
bool
handle_c
();
virtual
bool
handle_o
();
virtual
bool
handle_null
();
};
#endif
/* CONTEXTMAP_H_ */
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