summaryrefslogtreecommitdiff
path: root/test/nanoparticles.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/nanoparticles.rb')
-rw-r--r--test/nanoparticles.rb40
1 files changed, 36 insertions, 4 deletions
diff --git a/test/nanoparticles.rb b/test/nanoparticles.rb
index 46073a9..31bb903 100644
--- a/test/nanoparticles.rb
+++ b/test/nanoparticles.rb
@@ -11,9 +11,38 @@ class NanoparticleTest < MiniTest::Test
p dataset_ids.collect{|d| {d => Dataset.find(d).name}}
dataset_ids.collect do |d|
d = Dataset.find(d)
- p d.name
- puts d.to_csv
+ #p d.name
+ #puts d.to_csv
+ end
+ end
+
+ def test_summaries
+ features = Feature.all.to_a
+ #p features.collect do |f|
+ #f if f.category == "TOX"
+ #end.to_a.flatten.size
+ toxcounts = {}
+ pccounts = {}
+ Nanoparticle.all.each do |np|
+ np.toxicities.each do |t,v|
+ toxcounts[t] ||= 0
+ toxcounts[t] += 1#v.uniq.size
+ end
+ np.physchem_descriptors.each do |t,v|
+ pccounts[t] ||= 0
+ pccounts[t] += 1#v.uniq.size
+ end
end
+ #puts counts.keys.collect{|i| Feature.find(i)}.to_yaml
+ #pccounts.each{|e,n| p Feature.find(e),n if n > 100}
+ #p toxcounts.collect{|e,n| Feature.find(e).name if n > 1}.uniq
+ toxcounts.each{|e,n| p Feature.find(e),n if n > 100}
+ end
+
+
+ def test_import_ld
+ skip
+ dataset_ids = Import::Enanomapper.import_ld
end
def test_export
@@ -24,11 +53,14 @@ class NanoparticleTest < MiniTest::Test
def test_create_model
training_dataset = Dataset.find_or_create_by(:name => "Protein Corona Fingerprinting Predicts the Cellular Interaction of Gold and Silver Nanoparticles")
- model = Model::LazarRegression.create(training_dataset, :prediction_algorithm => "OpenTox::Algorithm::Regression.local_physchem_regression", :neighbor_algorithm => "nanoparticle_neighbors")
+ feature = Feature.find_or_create_by(name: "7.99 Toxicity (other) ICP-AES", category: "TOX", unit: "mL/ug(Mg)")
+ model = Model::LazarRegression.create(feature, training_dataset, {:prediction_algorithm => "OpenTox::Algorithm::Regression.local_physchem_regression", :neighbor_algorithm => "nanoparticle_neighbors"})
nanoparticle = training_dataset.nanoparticles[-34]
+ #p nanoparticle.neighbors
prediction = model.predict nanoparticle
p prediction
- refute_nil prediction[:value]
+ #p prediction
+ #refute_nil prediction[:value]
end
end