Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
chipathlon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
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
Holland Computing Center
chipathlon
Merge requests
!10
Minor fixes to the genome class
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Minor fixes to the genome class
genome-quick-fix
into
master
Overview
0
Commits
1
Changes
1
Merged
aknecht2
requested to merge
genome-quick-fix
into
master
8 years ago
Overview
0
Commits
1
Changes
1
Expand
Missed some stuff before merging. Oops.
0
0
Merge request reports
Compare
master
master (base)
and
latest version
latest version
1c0a6f48
1 commit,
8 years ago
1 file
+
23
−
28
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
chipathlon/genome.py
+
23
−
28
Options
@@ -36,14 +36,6 @@ class Genome(object):
self
.
chrom_sizes
)
def
_load_prefixes
(
self
):
self
.
file_prefix
=
"
genome_%s_%s
"
%
(
self
.
assembly
,
self
.
tool
)
self
.
add_file_prefix
=
self
.
file_prefix
if
self
.
tool
==
"
bowtie2
"
else
self
.
file_prefix
+
os
.
path
.
splitext
(
self
.
base_file
)[
1
]
bowtie2_path_prefix
,
base_ext
=
os
.
path
.
splitext
(
self
.
base_file
)
self
.
base_ext
=
base_ext
self
.
path_prefix
=
bowtie2_path_prefix
if
self
.
tool
==
"
bowtie2
"
else
self
.
base_file
return
def
is_valid
(
self
):
"""
Checks if the run is valid.
@@ -62,10 +54,28 @@ class Genome(object):
def
get_chrom_sizes
(
self
):
return
self
.
files
.
get
(
"
chrom_sizes
"
)
def
get_additional
(
self
,
gen_file_type
):
return
self
.
files
.
get
(
gen_file_type
)
def
get_additional_files
(
self
):
return
self
.
files
.
get
(
"
additional_files
"
)
def
get_chr_fasta_files
(
self
):
return
self
.
files
.
get
(
"
chr_fasta
"
)
def
_load_prefixes
(
self
):
self
.
file_prefix
=
"
genome_%s_%s
"
%
(
self
.
assembly
,
self
.
tool
)
self
.
add_file_prefix
=
self
.
file_prefix
if
self
.
tool
==
"
bowtie2
"
else
self
.
file_prefix
+
os
.
path
.
splitext
(
self
.
base_file
)[
1
]
bowtie2_path_prefix
,
base_ext
=
os
.
path
.
splitext
(
self
.
base_file
)
self
.
base_ext
=
base_ext
self
.
path_prefix
=
bowtie2_path_prefix
if
self
.
tool
==
"
bowtie2
"
else
self
.
base_file
return
def
_add_file
(
self
,
name
,
path
,
gen_file_type
=
"
base_file
"
):
"""
Adds a file to the internal files list. Files are indexed
by type. There should only be a single base_file / chrom.sizes
file, however there can and should be multiple additional genomic
files and individual chromsome fasta files. These additional inputs
will be maintained in a list.
"""
f
=
File
(
name
)
f
.
addPFN
(
PFN
(
path
,
"
local
"
))
if
gen_file_type
==
"
base_file
"
or
gen_file_type
==
"
chrom.sizes
"
:
@@ -99,33 +109,18 @@ class Genome(object):
return
def
_load_files
(
self
):
# Load in the base file / chromsome sizes file
self
.
_add_file
(
"
%s.%s
"
%
(
self
.
file_prefix
,
self
.
base_ext
),
self
.
base_file
,
"
base_file
"
)
self
.
_add_file
(
"
%s.chrom.sizes
"
%
(
self
.
file_prefix
,),
self
.
chrom_sizes
,
"
chrom.sizes
"
)
# Load each additional file
for
ext
in
chipathlon
.
conf
.
genomes
[
self
.
tool
][
"
additional_files
"
]:
name
=
"
%s.%s
"
%
(
self
.
add_file_prefix
,
ext
)
path
=
"
%s.%s
"
%
(
self
.
path_prefix
,
ext
)
self
.
_add_file
(
name
,
path
,
"
additional_files
"
)
# Load each individual chromsome fasta file
base_dir
=
os
.
path
.
dirname
(
os
.
path
.
dirname
(
self
.
chrom_sizes
+
"
/
"
))
for
root
,
dirs
,
files
in
os
.
walk
(
base_dir
):
for
f
in
files
:
if
f
.
startswith
(
"
chr
"
):
self
.
_add_file
(
"
%s_%s
"
%
(
self
.
add_file_prefix
,
f
),
root
+
"
/
"
+
f
,
"
chr_fasta
"
)
return
def
_valid_genome
(
self
,
run
):
"""
:param run: The run to check.
:type run: dict
Check that the provided run has a genome that exists.
"""
valid
=
False
if
run
[
"
genome
"
]
in
self
.
genomes
:
if
run
[
"
align
"
]
in
self
.
genomes
[
run
[
"
genome
"
]]:
valid
=
True
msg
=
"
Genome is valid.
"
else
:
msg
=
"
Alignment tool
'
%s
'
not defined for genome
'
%s
'
.
"
%
(
run
[
"
align
"
],
run
[
"
genome
"
])
else
:
msg
=
"
Run genome
'
%s
'
not defined in genome data.
"
%
(
run
[
"
genome
"
],)
return
(
valid
,
msg
)
Loading