Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
chipseq_analysis
Manage
Activity
Members
Labels
Plan
Issues
19
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
3
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container 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
BICF
Astrocyte
chipseq_analysis
Commits
cc0b8e05
Commit
cc0b8e05
authored
7 years ago
by
Venkat Malladi
Browse files
Options
Downloads
Patches
Plain Diff
generatlized strip_extension and added tests.
parent
6b2c56dc
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!5
Resolve "Add mapping and trimming"
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
workflow/scripts/map_reads.py
+4
-13
4 additions, 13 deletions
workflow/scripts/map_reads.py
workflow/scripts/utils.py
+10
-0
10 additions, 0 deletions
workflow/scripts/utils.py
workflow/tests/test_utils.py
+17
-0
17 additions, 0 deletions
workflow/tests/test_utils.py
with
31 additions
and
13 deletions
workflow/scripts/map_reads.py
+
4
−
13
View file @
cc0b8e05
...
...
@@ -59,15 +59,6 @@ def get_args():
## Functions
def
strip_extensions
(
filename
,
extensions
):
'''
Strips extensions to get basename of file.
'''
basename
=
filename
for
extension
in
extensions
:
basename
=
basename
.
rpartition
(
extension
)[
0
]
or
basename
return
basename
def
check_tools
():
'''
Checks for required componenets on user system
'''
...
...
@@ -92,7 +83,7 @@ def check_tools():
def
generate_sa
(
fastq
,
reference
):
'''
Use BWA to generate Suffix Arrays.
'''
fastq_basename
=
os
.
path
.
basename
(
strip_extensions
(
fastq
,
STRIP_EXTENSIONS
))
fastq_basename
=
os
.
path
.
basename
(
utils
.
strip_extensions
(
fastq
,
STRIP_EXTENSIONS
))
bwa_aln_params
=
'
-q 5 -l 32 -k 2
'
...
...
@@ -184,16 +175,16 @@ def main():
# Run alignment for either PE or SE
if
paired
:
# paired-end data
fastq_r1_basename
=
os
.
path
.
basename
(
strip_extensions
(
fastq
[
0
],
STRIP_EXTENSIONS
))
utils
.
strip_extensions
(
fastq
[
0
],
STRIP_EXTENSIONS
))
fastq_r2_basename
=
os
.
path
.
basename
(
strip_extensions
(
fastq
[
1
],
STRIP_EXTENSIONS
))
utils
.
strip_extensions
(
fastq
[
1
],
STRIP_EXTENSIONS
))
fastq_basename
=
fastq_r1_basename
+
fastq_r2_basename
bam_filename
=
align_pe
(
fastq
,
sai
,
reference
,
fastq_basename
)
else
:
fastq_basename
=
os
.
path
.
basename
(
strip_extensions
(
fastq
[
0
],
STRIP_EXTENSIONS
))
utils
.
strip_extensions
(
fastq
[
0
],
STRIP_EXTENSIONS
))
bam_filename
=
align_se
(
fastq
,
sai
,
reference
,
fastq_basename
)
...
...
This diff is collapsed.
Click to expand it.
workflow/scripts/utils.py
+
10
−
0
View file @
cc0b8e05
...
...
@@ -46,3 +46,13 @@ def run_pipe(steps, outfile=None):
p
=
p_next
out
,
err
=
p
.
communicate
()
return
out
,
err
def
strip_extensions
(
filename
,
extensions
):
'''
Strips extensions to get basename of file.
'''
basename
=
filename
for
extension
in
extensions
:
basename
=
basename
.
rpartition
(
extension
)[
0
]
or
basename
return
basename
This diff is collapsed.
Click to expand it.
workflow/tests/test_utils.py
+
17
−
0
View file @
cc0b8e05
...
...
@@ -6,6 +6,8 @@ import shlex
import
utils
STRIP_EXTENSIONS
=
[
'
.gz
'
,
'
.fq
'
,
'
.fastq
'
,
'
.fa
'
,
'
.fasta
'
]
@pytest.fixture
def
steps
():
steps
=
[]
...
...
@@ -51,3 +53,18 @@ def test_run_last_step_file(steps_2, capsys, tmpdir):
output
,
errors
=
capsys
.
readouterr
()
assert
"
last step shlex
"
in
output
assert
check_output
in
tmp_outfile
.
read
()
def
test_strip_extensions
():
filename
=
utils
.
strip_extensions
(
'
ENCFF833BLU.fastq.gz
'
,
STRIP_EXTENSIONS
)
assert
filename
==
'
ENCFF833BLU
'
def
test_strip_extensions_not_valid
():
filename
=
utils
.
strip_extensions
(
'
ENCFF833BLU.not.valid
'
,
STRIP_EXTENSIONS
)
assert
filename
==
'
ENCFF833BLU.not.valid
'
def
test_strip_extensions_missing_basename
():
filename
=
utils
.
strip_extensions
(
'
.fastq.gz
'
,
STRIP_EXTENSIONS
)
assert
filename
==
'
.fastq
'
This diff is collapsed.
Click to expand it.
Preview
0%
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