Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openbis
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sispub
openbis
Commits
7843d66b
Commit
7843d66b
authored
14 years ago
by
kohleman
Browse files
Options
Downloads
Patches
Plain Diff
initial import
SVN: 19218
parent
89a94cd2
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
deep_sequencing_unit/source/Python/bam2wig.py
+29
-0
29 additions, 0 deletions
deep_sequencing_unit/source/Python/bam2wig.py
with
29 additions
and
0 deletions
deep_sequencing_unit/source/Python/bam2wig.py
0 → 100644
+
29
−
0
View file @
7843d66b
#!/usr/bin/env python
# Manuel Kohler, ETH Zuerich, 12/2010
# Creates a Wiggle file out of a BAM file
# Prerequisite: BAM index file
# Documentation says: 'If an index for a BAM file exists (.bai), it will be opened automatically.
# Without an index random access to reads via fetch() and pileup() is disabled.'
import
sys
,
pysam
bamfile_name
=
sys
.
argv
[
1
]
bamfile
=
pysam
.
Samfile
(
bamfile_name
,
'
rb
'
)
wigfile_name
=
bamfile_name
.
replace
(
'
.bam
'
,
'
.wig
'
)
wigfile
=
open
(
wigfile_name
,
'
w
'
)
header_full
=
'
track type=wiggle_0 name=
'
+
wigfile_name
variable_wig
=
'
variableStep chrom=chr
'
print
>>
wigfile
,
header_full
for
gene_names
in
range
(
bamfile
.
nreferences
):
# UCSC conformity
if
bamfile
.
getrname
(
gene_names
)
==
'
dmel_mitochondrion_genome
'
:
print
>>
wigfile
,
variable_wig
+
'
M
'
else
:
print
>>
wigfile
,
variable_wig
+
bamfile
.
getrname
(
gene_names
)
for
pile
in
bamfile
.
pileup
(
bamfile
.
getrname
(
gene_names
)):
print
>>
wigfile
,
pile
.
pos
,
pile
.
n
bamfile
.
close
()
wigfile
.
close
()
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