Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
chipseq_analysis
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
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
Astrocyte
Workflows
BICF
chipseq_analysis
Commits
4c3add75
There was an error fetching the commit references. Please try again later.
Commit
4c3add75
authored
6 years ago
by
Venkat Malladi
Browse files
Options
Downloads
Patches
Plain Diff
Update mapped reads with sample id.
parent
b1c3fb87
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
workflow/main.nf
+3
-3
3 additions, 3 deletions
workflow/main.nf
workflow/scripts/map_reads.py
+10
-17
10 additions, 17 deletions
workflow/scripts/map_reads.py
workflow/tests/test_map_reads.py
+4
-4
4 additions, 4 deletions
workflow/tests/test_map_reads.py
with
17 additions
and
24 deletions
workflow/main.nf
+
3
−
3
View file @
4c3add75
...
...
@@ -129,18 +129,18 @@ process alignReads {
output:
set sampleId, file('*.bam'), experimentId, biosample, factor, treatment, replicate, controlId into mappedReads
file '*.
srt.bam.
flagstat.qc' into mappedReadsStats
file '*.flagstat.qc' into mappedReadsStats
script:
if (pairedEnd) {
"""
python3 $baseDir/scripts/map_reads.py -f ${reads[0]} ${reads[1]} -r ${index}/genome.fa -p
python3 $baseDir/scripts/map_reads.py -f ${reads[0]} ${reads[1]} -r ${index}/genome.fa
-s $sampleId
-p
"""
}
else {
"""
python3 $baseDir/scripts/map_reads.py -f $reads -r ${index}/genome.fa
python3 $baseDir/scripts/map_reads.py -f $reads -r ${index}/genome.fa
-s $sampleId
"""
}
...
...
This diff is collapsed.
Click to expand it.
workflow/scripts/map_reads.py
+
10
−
17
View file @
4c3add75
...
...
@@ -24,16 +24,10 @@ logger.addHandler(logging.NullHandler())
logger
.
propagate
=
False
logger
.
setLevel
(
logging
.
INFO
)
# the order of this list is important.
# strip_extensions strips from the right inward, so
# the expected right-most extensions should appear first (like .gz)
# Modified from J. Seth Strattan
STRIP_EXTENSIONS
=
[
'
.gz
'
,
'
.fq
'
,
'
.fastq
'
,
'
_trimmed
'
]
def
get_args
():
'''
Define arguments.
'''
parser
=
argparse
.
ArgumentParser
(
description
=
__doc__
,
epilog
=
EPILOG
,
formatter_class
=
argparse
.
RawDescriptionHelpFormatter
)
...
...
@@ -47,6 +41,10 @@ def get_args():
help
=
"
The bwa index of the reference genome.
"
,
required
=
True
)
parser
.
add_argument
(
'
-s
'
,
'
--sample
'
,
help
=
"
The name of the sample.
"
,
required
=
True
)
parser
.
add_argument
(
'
-p
'
,
'
--paired
'
,
help
=
"
True/False if paired-end or single end.
"
,
default
=
False
,
...
...
@@ -157,6 +155,7 @@ def main():
paired
=
args
.
paired
fastq
=
args
.
fastq
reference
=
args
.
reference
sample
=
args
.
sample
# Create a file handler
handler
=
logging
.
FileHandler
(
'
map.log
'
)
...
...
@@ -171,23 +170,17 @@ def main():
sai_filename
=
generate_sa
(
fq
,
reference
)
sai
.
append
(
sai_filename
)
# Make file basename
fastq_basename
=
sample
# Run alignment for either PE or SE
if
paired
:
# paired-end data
fastq_r1_basename
=
os
.
path
.
basename
(
utils
.
strip_extensions
(
fastq
[
0
],
STRIP_EXTENSIONS
))
fastq_r2_basename
=
os
.
path
.
basename
(
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
(
utils
.
strip_extensions
(
fastq
[
0
],
STRIP_EXTENSIONS
))
bam_filename
=
align_se
(
fastq
,
sai
,
reference
,
fastq_basename
)
bam_mapstats_filename
=
'
%s.
srt.bam.
flagstat.qc
'
%
(
fastq_basename
)
bam_mapstats_filename
=
'
%s.flagstat.qc
'
%
(
fastq_basename
)
with
open
(
bam_mapstats_filename
,
'
w
'
)
as
fh
:
subprocess
.
check_call
(
shlex
.
split
(
"
samtools flagstat %s
"
%
(
bam_filename
)),
...
...
This diff is collapsed.
Click to expand it.
workflow/tests/test_map_reads.py
+
4
−
4
View file @
4c3add75
...
...
@@ -9,8 +9,8 @@ test_output_path = os.path.dirname(os.path.abspath(__file__)) + \
@pytest.mark.singleend
def
test_map_reads_singleend
():
assert
os
.
path
.
exists
(
os
.
path
.
join
(
test_output_path
,
'
ENC
FF646LXU.srt
.bam
'
))
aligned_reads_report
=
test_output_path
+
'
ENC
FF646LXU.srt.bam
.flagstat.qc
'
assert
os
.
path
.
exists
(
os
.
path
.
join
(
test_output_path
,
'
ENC
LB831RUI
.bam
'
))
aligned_reads_report
=
test_output_path
+
'
ENC
LB831RUI
.flagstat.qc
'
samtools_report
=
open
(
aligned_reads_report
).
readlines
()
assert
'
80795025 + 0 in total
'
in
samtools_report
[
0
]
assert
'
80050072 + 0 mapped (99.08% : N/A)
'
in
samtools_report
[
4
]
...
...
@@ -18,8 +18,8 @@ def test_map_reads_singleend():
@pytest.mark.pairedend
def
test_map_reads_pairedend
():
assert
os
.
path
.
exists
(
os
.
path
.
join
(
test_output_path
,
'
ENC
FF002DTU_val_1ENCFF002EFI_val_2.srt
.bam
'
))
aligned_reads_report
=
test_output_path
+
'
ENC
FF002DTU_val_1ENCFF002EFI_val_2.srt.bam
.flagstat.qc
'
assert
os
.
path
.
exists
(
os
.
path
.
join
(
test_output_path
,
'
ENC
LB678IDC
.bam
'
))
aligned_reads_report
=
test_output_path
+
'
ENC
LB678IDC
.flagstat.qc
'
samtools_report
=
open
(
aligned_reads_report
).
readlines
()
assert
'
72660890 + 0 in total
'
in
samtools_report
[
0
]
assert
'
72053925 + 0 mapped (99.16% : N/A)
'
in
samtools_report
[
4
]
...
...
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