-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e130f81
commit 0dc7173
Showing
20 changed files
with
1,270 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
#!/usr/bin/env ruby | ||
#!/usr/bin/env ruby | ||
|
||
require 'fileutils' | ||
|
||
# Client script for model_calibrate. Builds and scores svmfp models | ||
# using svmfp_make and svmfp_evaluate. | ||
|
||
require_relative 'lib/iwcmdline' | ||
|
||
def usage(rc) | ||
exit(rc) | ||
end | ||
|
||
def main | ||
cl = IWCmdline.new("-v-gfp=close-TRSMI=sfile-TESMI=sfile-TRactivity=sfile-TEactivity=sfile-PRED=s-STATS=s-TMPDIR=s-uid=s") | ||
|
||
unless cl.option_present('gfp') | ||
$stderr << "Must specify fingerprints via the -gfp option\n" | ||
usage(1) | ||
end | ||
|
||
unless cl.option_present('TRactivity') | ||
$stderr << "Must specify training set activity file via the -TRactivity option\n" | ||
usage(1) | ||
end | ||
|
||
unless cl.option_present('TEactivity') | ||
$stderr << "Must specify testing set activity file via the -TEactivity option\n" | ||
usage(1) | ||
end | ||
|
||
unless cl.option_present('PRED') | ||
$stderr << "Must specify predicted values file via the -PRED option\n" | ||
usage(1) | ||
end | ||
|
||
unless cl.option_present('STATS') | ||
$stderr << "Must specify statistics file via the -STATS option\n" | ||
usage(1) | ||
end | ||
|
||
if cl.option_present('TMPDIR') | ||
tmpdir = cl.value('TMPDIR') | ||
elsif cl.option_present('uid') | ||
uid = cl.value('uid') | ||
tmpdir = "/tmp/calibrate_#{uid}" | ||
else | ||
$stderr << "Must specify either -TMPDIR or unique identifier via the -uid option\n" | ||
usage(1) | ||
end | ||
|
||
trsmi = cl.value('TRSMI') | ||
tesmi = cl.value('TESMI') | ||
|
||
Dir.mkdir(tmpdir) unless File.directory?(tmpdir) | ||
|
||
if cl.unrecognised_options_encountered | ||
$stderr << "Unrecognised options encountered\n" | ||
usage(1) | ||
end | ||
|
||
verbose = cl.option_present('v') | ||
|
||
lillymol_home = ENV['LILLYMOL_HOME'] | ||
svmfp_make = "#{lillymol_home}/contrib/bin/svmfp/svmfp_make.sh" | ||
svmfp_evaluate = "#{lillymol_home}/contrib/bin/svmfp/svmfp_evaluate.sh" | ||
|
||
gfp = cl.value('gfp') | ||
train_activity = cl.value('TRactivity') | ||
test_activity = cl.value('TEactivity') | ||
|
||
predicted = cl.value('PRED') | ||
|
||
results = cl.value('STATS') | ||
|
||
mdir = File.join(tmpdir, 'MODEL') | ||
|
||
cmd = "#{svmfp_make} --mdir #{mdir} -gfp #{gfp} -gfp -A #{train_activity} #{trsmi}" | ||
system(cmd) | ||
|
||
cmd = "#{svmfp_evaluate} -mdir #{mdir} #{tesmi} > #{predicted}" | ||
system(cmd) | ||
|
||
cmd = "iwstats -w -Y allequals -E #{test_activity} -p 2 #{predicted} > #{results}" | ||
system(cmd) | ||
|
||
FileUtils.rm_rf(tmpdir) | ||
end | ||
|
||
main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/bash | ||
set -x | ||
ruby_script="${0%%.sh}.rb" | ||
exec ruby ${ruby_script} "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -86,9 +86,6 @@ def main | |
system(cmd) | ||
|
||
FileUtils.rm_rf(tmpdir) | ||
|
||
File.unlink(tmptrain) | ||
File.unlink(tmptest) | ||
end | ||
|
||
main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
ruby_script="${0%%.sh}.rb" | ||
exec ruby ${ruby_script} "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# frozen_string_literal: true | ||
|
||
# Part of gfp_make | ||
|
||
# Report to stderr the recognized fingerprints in `fps`. | ||
def report_recognized_fingerprints(fps) | ||
$stderr << "#{fps.length} fingerprints recognized\n" | ||
fps.each do |k, v| | ||
$stderr << "#{k} #{v} #{v.description}\n" | ||
end | ||
end | ||
|
||
# Return a map of fingerprint names to object that can process | ||
# that kind of fingerprint. | ||
# By convention, the name of the class is the uppercase of | ||
# the config file name. | ||
# config_dirs is an array of directories in which to look. | ||
# If multiple items are found, the last will be silently used. | ||
|
||
def config_fingerprints(config_dirs, verbose) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity | ||
fps = {} # To be returned. | ||
config_dirs.each do |dir| | ||
$stderr << "Fetching configs from #{dir}\n" if verbose.positive? | ||
Dir.entries(dir).each do |fname| | ||
next if /^\./.match(fname) | ||
next if fname == 'fp_common.rb' | ||
next if fname == 'lib' | ||
|
||
m = /^(\S+)\.rb/.match(fname) | ||
unless m | ||
$stderr << "No match file name #{fname}, ignored\n" | ||
next | ||
end | ||
require("#{dir}/#{fname}") | ||
class_name = m[1].upcase # By convention. | ||
fps[class_name] = eval("#{class_name}.new", binding, __FILE__, __LINE__) # rubocop:disable Security/Eval | ||
end | ||
end | ||
|
||
report_recognized_fingerprints(fps) if verbose.positive? | ||
|
||
fps | ||
end |
Oops, something went wrong.