Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
cami
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Chow Castro, Marcos
cami
Commits
eae22010
Commit
eae22010
authored
2 years ago
by
Le, Mia
Browse files
Options
Downloads
Patches
Plain Diff
added new wrappers
parent
56798bba
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
cami_src/algorithms/CustomWrapper.py
+49
-0
49 additions, 0 deletions
cami_src/algorithms/CustomWrapper.py
with
49 additions
and
0 deletions
cami_src/algorithms/CustomWrapper.py
0 → 100644
+
49
−
0
View file @
eae22010
from
algorithms.AlgorithmWrapper
import
AlgorithmWrapper
import
subprocess
from
configparser
import
ConfigParser
class
CustomWrapper
(
AlgorithmWrapper
):
def
__init__
(
self
,
config
):
"""
Wrapper that allows to use results from any algorithm that is not included in the CAMI suite yet
has a class variable
'
external_prediction_path
'
that points to the path of the external prediction file
"""
super
().
__init__
(
config
)
self
.
name
=
'
custom_algorithm
'
self
.
code
=
-
1
self
.
external_prediction_path
=
'
path/to/external/prediction/file
'
ppi_vertex2gene
=
self
.
ppi_graph
.
vertex_properties
[
"
name
"
]
self
.
ppi_gene2vertex
=
{
ppi_vertex2gene
[
vertex
]:
vertex
for
vertex
in
self
.
ppi_graph
.
vertices
()}
def
run_algorithm
(
self
,
inputparams
):
"""
extract the output from the external prediction file, that contains the name of the external tool in the first line
set the name for the algorithm to the name of the external tool
Args:
inputparams (list): A list of parameters for the algorithm that is defined via
prepare_input()
Returns:
list: A list of resulting genes extracted from the generated output file
"""
external_prediction_file
=
inputparams
[
0
]
result_list
=
[]
with
open
(
external_prediction_file
)
as
rfile
:
for
idx
,
line
in
enumerate
(
rfile
):
if
idx
==
0
:
self
.
name
=
line
.
strip
()
else
:
node
=
line
.
strip
()
if
node
in
self
.
ppi_gene2vertex
:
result_list
.
append
(
self
.
ppi_gene2vertex
[
node
])
return
result_list
def
prepare_input
(
self
):
"""
this function returns the path to the external prediction file
"""
return
self
.
external_prediction_path
def
extract_output
(
self
,
algo_output
):
"""
this function does not do anything in the case of an external algorithm
"""
pass
\ No newline at end of file
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