Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bob.bio.base
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
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
bob
bob.bio.base
Commits
44e531de
There was a problem fetching the pipeline summary.
Commit
44e531de
authored
6 years ago
by
Amir MOHAMMADI
Browse files
Options
Downloads
Patches
Plain Diff
Fix a bug when neg and pos scores were swapped
parent
f18ee18a
No related branches found
No related tags found
1 merge request
!146
Add 4-5-col files related functionalities and add click commands
Pipeline
#
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bob/bio/base/script/gen.py
+11
-7
11 additions, 7 deletions
bob/bio/base/script/gen.py
with
11 additions
and
7 deletions
bob/bio/base/script/gen.py
+
11
−
7
View file @
44e531de
"""
Generate random scores.
"""
Generate random scores.
"""
"""
import
pkg_resources
# to make sure bob gets imported properly
import
os
import
os
import
logging
import
logging
import
numpy
import
numpy
...
@@ -16,6 +15,7 @@ logger = logging.getLogger(__name__)
...
@@ -16,6 +15,7 @@ logger = logging.getLogger(__name__)
NUM_NEG
=
5000
NUM_NEG
=
5000
NUM_POS
=
5000
NUM_POS
=
5000
def
gen_score_distr
(
mean_neg
,
mean_pos
,
sigma_neg
=
10
,
sigma_pos
=
10
):
def
gen_score_distr
(
mean_neg
,
mean_pos
,
sigma_neg
=
10
,
sigma_pos
=
10
):
"""
Generate scores from normal distributions
"""
Generate scores from normal distributions
...
@@ -47,15 +47,16 @@ def gen_score_distr(mean_neg, mean_pos, sigma_neg=10, sigma_pos=10):
...
@@ -47,15 +47,16 @@ def gen_score_distr(mean_neg, mean_pos, sigma_neg=10, sigma_pos=10):
return
neg_scores
,
pos_scores
return
neg_scores
,
pos_scores
def
write_scores_to_file
(
pos
,
neg
,
filename
,
n_sys
=
1
,
five_col
=
False
):
def
write_scores_to_file
(
neg
,
pos
,
filename
,
n_sys
=
1
,
five_col
=
False
):
"""
Writes score distributions
"""
Writes score distributions
Parameters
Parameters
----------
----------
pos : :py:class:`numpy.ndarray`
Scores for positive samples.
neg : :py:class:`numpy.ndarray`
neg : :py:class:`numpy.ndarray`
Scores for negative samples.
Scores for negative samples.
pos : :py:class:`numpy.ndarray`
Scores for positive samples.
filename : str
filename : str
The path to write the score to.
The path to write the score to.
n_sys : int
n_sys : int
...
@@ -68,13 +69,16 @@ def write_scores_to_file(pos, neg, filename, n_sys=1, five_col=False):
...
@@ -68,13 +69,16 @@ def write_scores_to_file(pos, neg, filename, n_sys=1, five_col=False):
with
open
(
filename
,
'
wt
'
)
as
f
:
with
open
(
filename
,
'
wt
'
)
as
f
:
for
i
in
pos
:
for
i
in
pos
:
s_name
=
random
.
choice
(
s_names
)
s_name
=
random
.
choice
(
s_names
)
s_five
=
'
'
if
not
five_col
else
'
d
'
+
random
.
choice
(
s_names
)
+
'
'
s_five
=
'
'
if
not
five_col
else
'
d
'
+
\
random
.
choice
(
s_names
)
+
'
'
f
.
write
(
'
x%sx %s %f
\n
'
%
(
s_five
,
s_name
,
i
))
f
.
write
(
'
x%sx %s %f
\n
'
%
(
s_five
,
s_name
,
i
))
for
i
in
neg
:
for
i
in
neg
:
s_name
=
random
.
choice
(
s_names
)
s_name
=
random
.
choice
(
s_names
)
s_five
=
'
'
if
not
five_col
else
'
d
'
+
random
.
choice
(
s_names
)
+
'
'
s_five
=
'
'
if
not
five_col
else
'
d
'
+
\
random
.
choice
(
s_names
)
+
'
'
f
.
write
(
'
x%sy %s %f
\n
'
%
(
s_five
,
s_name
,
i
))
f
.
write
(
'
x%sy %s %f
\n
'
%
(
s_five
,
s_name
,
i
))
@click.command
()
@click.command
()
@click.argument
(
'
outdir
'
)
@click.argument
(
'
outdir
'
)
@click.option
(
'
-mm
'
,
'
--mean-match
'
,
default
=
10
,
type
=
FLOAT
,
show_default
=
True
)
@click.option
(
'
-mm
'
,
'
--mean-match
'
,
default
=
10
,
type
=
FLOAT
,
show_default
=
True
)
...
@@ -84,7 +88,7 @@ def write_scores_to_file(pos, neg, filename, n_sys=1, five_col=False):
...
@@ -84,7 +88,7 @@ def write_scores_to_file(pos, neg, filename, n_sys=1, five_col=False):
@verbosity_option
()
@verbosity_option
()
def
gen
(
outdir
,
mean_match
,
mean_non_match
,
n_sys
,
five_col
):
def
gen
(
outdir
,
mean_match
,
mean_non_match
,
n_sys
,
five_col
):
"""
Generate random scores.
"""
Generate random scores.
Generates random scores in 4col or 5col format. The scores are generated
Generates random scores in 4col or 5col format. The scores are generated
using Gaussian distribution whose mean is an input
using Gaussian distribution whose mean is an input
parameter. The generated scores can be used as hypothetical datasets.
parameter. The generated scores can be used as hypothetical datasets.
"""
"""
...
...
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