Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
genotoul-bioinfo
ng6
Commits
2e698870
Commit
2e698870
authored
Jan 06, 2020
by
Romain Therville
☕
Browse files
Merge branch 'issue#153' into 'master'
Merge branch issue#153 with master See merge request
!75
parents
96df9089
edcc9cc2
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/ng6/utils.py
View file @
2e698870
...
...
@@ -361,6 +361,17 @@ class Utils(object):
return "".join(dec)
"""
@
staticmethod
def
get_project_dirname
(
project_id
,
project_name
):
return
"Project_%s.%s"
%
(
re
.
sub
(
r
"[\s\/]"
,
"_"
,
project_name
),
project_id
)
@
staticmethod
def
get_run_dirname
(
run_id
,
run_name
):
return
"Run_%s.%s"
%
(
re
.
sub
(
r
"[^A-Za-z0-9]"
,
"_"
,
run_name
),
run_id
)
@
staticmethod
def
get_analyse_dirname
(
analyse_id
,
analyse_name
):
return
"Analyse_%s.%s"
%
(
re
.
sub
(
r
"[\s\/]"
,
"_"
,
analyse_name
),
analyse_id
)
@
staticmethod
def
get_directories_structure_and_content
(
ng6_username
,
data_folder
,
output_folder
,
prefixed_ids
):
from
ng6.t3MySQLdb
import
t3MySQLdb
...
...
@@ -372,6 +383,7 @@ class Utils(object):
try
:
user_id
=
t3mysql
.
get_user_id
(
ng6_username
)
except
:
pass
for
prefixed_id
in
prefixed_ids
.
split
(
';'
)
:
vals
=
prefixed_id
.
split
(
'_'
)
prefix
=
vals
[
0
]
...
...
@@ -380,10 +392,10 @@ class Utils(object):
if
prefix
==
"data"
or
prefix
==
"run"
:
run
=
t3mysql
.
select_run_informations
(
id
)
source_dir
=
data_folder
+
'/'
+
run
[
'directory'
]
project_name
=
"Project_%s.%s"
%
(
re
.
sub
(
r
"[\s\/]"
,
"_"
,
run
[
'project_
name'
]),
run
[
'project_
id
'
]
)
project_name
=
Utils
.
get_project_dirname
(
run
[
'project_
id'
],
run
[
'project_
name
'
])
#run_name = "Run_%s.%s" %( run['name'].replace(' ', '_').replace('/', '_'), id )
run_name
=
"Run_%s.%s"
%
(
re
.
sub
(
r
"[^A-Za-z0-9]"
,
"_"
,
run
[
'name'
])
,
id
)
run_name
=
Utils
.
get_run_dirname
(
id
,
run
[
'name'
])
raw_data_dir
=
os
.
path
.
join
(
output_folder
,
project_name
,
run_name
,
"RawData"
)
if
source_dir
not
in
src_directories
:
...
...
@@ -394,7 +406,7 @@ class Utils(object):
if
prefix
==
"run"
:
for
analyse_id
,
analyse_values
in
t3mysql
.
get_user_run_analysis
(
user_id
,
id
,
'tx_nG6_analyze.name'
).
items
()
:
analysis_dir
=
data_folder
+
'/'
+
analyse_values
[
"directory"
]
analysis_name
=
"Analyse_%s.%s"
%
(
re
.
sub
(
r
"[\s\/]"
,
"_"
,
analyse_values
[
'name'
]
),
analyse_id
)
analysis_name
=
Utils
.
get_analyse_dirname
(
analyse_id
,
analyse_values
[
'name'
]
)
dest_analysis_dir
=
os
.
path
.
join
(
output_folder
,
project_name
,
run_name
,
analysis_name
)
if
analysis_dir
not
in
src_directories
:
...
...
@@ -409,19 +421,19 @@ class Utils(object):
if
source_dir
not
in
src_directories
:
src_directories
.
append
(
source_dir
)
project_name
=
"Project_%s.%s"
%
(
re
.
sub
(
r
"[\s\/]"
,
"_"
,
analyse
[
"project_name"
]),
analyse
[
"project_id"
])
project_name
=
Utils
.
get_project_dirname
(
analyse
[
'project_id'
],
analyse
[
'project_name'
])
# it's a run analysis
if
analyse
[
"run_id"
]:
run_name
=
"Run_%s.%s"
%
(
re
.
sub
(
r
"[\s\/]"
,
"_"
,
analyse
[
"run_
name
"
]
)
,
analyse
[
"run_
id
"
])
analysis_name
=
"Analyse_%s.%s"
%
(
re
.
sub
(
r
"[\s\/]"
,
"_"
,
analyse
[
"
name
"
]),
id
)
if
analyse
[
"run_id"
]:
run_name
=
Utils
.
get_run_dirname
(
analyse
[
"run_
id
"
],
analyse
[
"run_
name
"
])
analysis_name
=
Utils
.
get_analyse_dirname
(
id
,
analyse
[
'
name
'
]
)
dest_analysis_dir
=
os
.
path
.
join
(
output_folder
,
project_name
,
run_name
,
analysis_name
)
if
dest_analysis_dir
not
in
dest_directories
:
dest_directories
.
append
(
dest_analysis_dir
)
# it's a project analysis
else
:
analysis_name
=
"Project_
analyses/%s.%s"
%
(
re
.
sub
(
r
"[\s\/]"
,
"_"
,
analyse
[
"
name
"
]),
id
)
analysis_name
=
"Project_
"
+
Utils
.
get_analyse_dirname
(
id
,
analyse
[
'
name
'
]
)
dest_analysis_dir
=
os
.
path
.
join
(
output_folder
,
project_name
,
analysis_name
)
if
dest_analysis_dir
not
in
dest_directories
:
dest_directories
.
append
(
dest_analysis_dir
)
...
...
Write
Preview
Supports
Markdown
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!
Cancel
Please
register
or
sign in
to comment