Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
miRBooking
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
Major Lab
miRBooking
Commits
707ad6d6
Commit
707ad6d6
authored
5 years ago
by
Guillaume Poirier-Morency
Browse files
Options
Downloads
Patches
Plain Diff
mirbooking-iterative: Various fixes and improvements
parent
2c5c7c51
No related branches found
No related tags found
1 merge request
!20
Add an option to blacklist interactions and support iterative equilibrium solving (fix #82)
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bin/mirbooking-iterative
+23
-9
23 additions, 9 deletions
bin/mirbooking-iterative
with
23 additions
and
9 deletions
bin/mirbooking-iterative
+
23
−
9
View file @
707ad6d6
...
...
@@ -9,24 +9,38 @@ import tempfile
def
main
(
argv
):
parser
=
argparse
.
ArgumentParser
()
# we need to intercept these arguments
parser
.
add_argument
(
'
--cutoff
'
,
type
=
float
,
required
=
True
)
parser
.
add_argument
(
'
--cutoff
'
,
type
=
float
,
default
=
100.0
)
parser
.
add_argument
(
'
--output
'
,
required
=
True
)
parser
.
add_argument
(
'
--output-format
'
,
default
=
'
tsv
'
)
args
,
mirbooking_args
=
parser
.
parse_known_args
(
argv
)
target_cutoff
=
args
.
cutoff
# this is generally a good starting point
cutoff
=
1000.0
blacklist
=
pd
.
DataFrame
(
columns
=
[
'
target_accession
'
,
'
position
'
,
'
mirna_accession
'
])
while
cutoff
>
target_cutoff
:
with
tempfile
.
NamedTemporaryFile
()
as
blacklistf
:
while
True
:
with
tempfile
.
NamedTemporaryFile
()
as
blacklistf
,
tempfile
.
NamedTemporaryFile
()
as
output
:
blacklist
.
to_csv
(
blacklistf
.
name
,
sep
=
'
\t
'
,
index
=
False
)
mirbooking_final_args
=
[
'
mirbooking
'
]
+
mirbooking_args
+
[
'
--blacklist
'
,
blacklistf
.
name
,
'
--cutoff
'
,
str
(
cutoff
),
'
--output
'
,
args
.
output
]
print
(
f
'
Running mirbooking with cutoff
{
cutoff
}
and
{
len
(
blacklist
)
}
blacklisted interactions.
'
)
mirbooking_final_args
=
[
'
mirbooking
'
]
+
mirbooking_args
+
[
'
--blacklist
'
,
blacklistf
.
name
,
'
--cutoff
'
,
str
(
cutoff
)]
if
cutoff
<=
target_cutoff
:
# emit what the user is asking for
mirbooking_final_args
.
extend
([
'
--output
'
,
args
.
output
,
'
--output-format
'
,
args
.
output_format
])
else
:
# emit an intermediate output model in TSV
mirbooking_final_args
.
extend
([
'
--output
'
,
output
.
name
,
'
--output-format
'
,
'
tsv
'
])
print
(
f
'
Running mirbooking with cutoff of
{
cutoff
:
.
2
f
}
pM and
{
len
(
blacklist
)
}
blacklisted interactions.
'
)
ret
=
subprocess
.
run
(
mirbooking_final_args
)
if
ret
.
returncode
!=
0
:
break
df
=
pd
.
read_csv
(
args
.
output
,
sep
=
'
\t
'
)
# filter out interactions that do not meet the target cutoff
blacklist
.
append
(
df
[
df
.
quantity
<
target_cutoff
][
blacklist
.
columns
])
cutoff
/=
1.5
# done, this is the last model we want to calculate
if
cutoff
<=
target_cutoff
:
break
# filter out interactions that do not meet the target cutoff from the intermediate output
df
=
pd
.
read_csv
(
output
.
name
,
sep
=
'
\t
'
)
blacklist
=
blacklist
.
append
(
df
[
df
.
quantity
<
target_cutoff
][
blacklist
.
columns
])
cutoff
/=
1.1
if
__name__
==
'
__main__
'
:
sys
.
exit
(
main
(
sys
.
argv
))
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