qsar-report 0.0.3 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 64a39f9e1511d0f8f585aa3fa316dbd349d6c30f
4
- data.tar.gz: 1fe77d4ed35aeba2d7927eae6608f7a1ddee36c1
3
+ metadata.gz: 7f4eb903541790a70f75536d9a479931568d78c1
4
+ data.tar.gz: 3ee7d2eb7c9aeb953f8cc5a604875e5e3db776ca
5
5
  SHA512:
6
- metadata.gz: eff30e0c0d94da86a568f967a46fb13cc5e6fcf893b953aa1bb809748946b12151fa271b04945049c04017c56d419385c7cbc5c1b2c0c1215c865df991619bfb
7
- data.tar.gz: 18a34a213877e2025b9aebe47ec61e4921a4152645dca17b742a3bda525dd1341eaceb954687dd3725d9e4a3ba507ccdcc6a8bbcc763d1ce46608d6b699ab07f
6
+ metadata.gz: 3025e42a8db242ba857ce87361d7d8a8b68a105d77af4b8685d5c66fd55de3f14271c5bc4a6d46968091a1079595dd06097ecde7b8ea69b02027226bbd90d15d
7
+ data.tar.gz: 229534ccc474849391e8af3cbaf263d602771903aac5fd59a5f2eb5b5052669a31484228ca8f664ebd10015f602878f7bf8b8f0d0d484a8419ae3b8b065f2424
data/.gitignore CHANGED
@@ -1,2 +1,3 @@
1
1
  *.*~
2
2
  *~
3
+ tmp/
data/README.md CHANGED
@@ -20,6 +20,9 @@ report = OpenTox::QMRFReport.new
20
20
  # add a title
21
21
  report.value "QSAR_title", "My QSAR Title"
22
22
 
23
+ # change 6.2 'Available information for the training set' set inchi and smiles to Yes
24
+ report.change_attributes "training_set_data", {:inchi => "Yes", :smiles => "Yes"}
25
+
23
26
  # add a publication to the publication catalog
24
27
  report.change_catalog :publications_catalog, :publications_catalog_1, {:title => "MyName M (2016) My Publication Title, QSAR News, 10, 14-22", :url => "http://myqsarnewsmag.dom"}
25
28
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.3
1
+ 0.0.5
data/lib/qmrf-report.rb CHANGED
@@ -11,6 +11,7 @@ module OpenTox
11
11
  # require "qsar-report"
12
12
  # report = OpenTox::QMRFReport.new
13
13
  # report.value "QSAR_title", "My QSAR Title"
14
+ # report.change_attributes "training_set_data", {:inchi => "Yes", :smiles => "Yes"}
14
15
  # report.change_catalog :publications_catalog, :publications_catalog_1, {:title => "MyName M (2016) My Publication Title, QSAR News, 10, 14-22", :url => "http://myqsarnewsmag.dom"}
15
16
  # report.ref_catalog :bibliography, :publications_catalog, :publications_catalog_1
16
17
  # puts report.to_xml
@@ -20,6 +21,8 @@ module OpenTox
20
21
  SCHEMA_FILE = File.join(File.dirname(__FILE__),"template/qmrf.xsd")
21
22
  # QMRF XML Template file
22
23
  TEMPLATE_FILE = File.join(File.dirname(__FILE__),"template/qmrf.xml")
24
+ # QMRF XML tags with attributes to edit
25
+ ATTRIBUTE_TAGS = ["training_set_availability", "training_set_data", "training_set_descriptors", "dependent_var_availability", "validation_set_availability", "validation_set_data", "validation_set_descriptors", "validation_dependent_var_availability"]
23
26
 
24
27
  attr_accessor :xml, :report
25
28
 
@@ -55,6 +58,21 @@ module OpenTox
55
58
  t.content
56
59
  end
57
60
 
61
+ # Set attributes of an report XML tag
62
+ # e.G.: <training_set_data cas="Yes" chapter="6.2" chemname="Yes" formula="Yes" help="" inchi="Yes" mol="Yes" name="Available information for the training set" smiles="Yes"/>
63
+ #@example change_attributes
64
+ # report.change_attributes "training_set_data", {:inchi => "Yes", :smiles => "Yes"}
65
+ # @param [String] key Nodename e.g.: "training_set_data"
66
+ # @param [Hash] valuehash Key-Value Hash of tag attributes to change.
67
+ # @return [Error] returns Error message if fails
68
+ def change_attributes tagname, valuehash
69
+ raise "Can not edit the attributes of tag: #{tagname}." unless ATTRIBUTE_TAGS.include? tagname
70
+ tag = @report.at_css tagname
71
+ valuehash.each do |key, value|
72
+ tag.attributes["#{key}"].value = value
73
+ end
74
+ end
75
+
58
76
  # Change a catalog
59
77
  # @param [String] catalog Name of the catalog - One of "software_catalog", "algorithms_catalog", "descriptors_catalog", "endpoints_catalog", "publications_catalog", "authors_catalog" in QMRF v1.3
60
78
  # @param [String] id Single entry node in the catalog e.G.: "<software contact='mycontact@mydomain.dom' description="My QSAR Software " id="software_catalog_2" name="MySoftware" number="" url="https://mydomain.dom"/>
@@ -62,9 +80,9 @@ module OpenTox
62
80
  # @return [Error] returns Error message if fails
63
81
  def change_catalog catalog, id, valuehash
64
82
  catalog_exists? catalog
65
- if @report.at_css("#{catalog}").at("//*[@id='#{id}']")
83
+ if @report.at_css("#{catalog}").at("[@id='#{id}']")
66
84
  valuehash.each do |key, value|
67
- @report.at_css("#{catalog}").at("//*[@id='#{id}']")["#{key}"]= value
85
+ @report.at_css("#{catalog}").at("[@id='#{id}']")["#{key}"]= value
68
86
  end
69
87
  else
70
88
  cat = @report.at_css("#{catalog}")
@@ -88,7 +106,7 @@ module OpenTox
88
106
  catalog_exists? catalog
89
107
  if @report.at_css("#{catalog}").at("//*[@id='#{id}']")
90
108
  chap = @report.at_css("#{chapter}")
91
- if chap.at("//*[@idref='#{id}']").nil?
109
+ if chap.at("[@idref='#{id}']").nil?
92
110
  newentry = Nokogiri::XML::Node.new("#{catalog.to_s.gsub(/s?_catalog/,'_ref')}", self.report)
93
111
  newentry["idref"] = id
94
112
  chap << newentry
@@ -105,8 +123,8 @@ module OpenTox
105
123
  # @return [String, false] returns value of a key in a catalog node or false if catalog entry do not exists.
106
124
  def get_catalog_value catalog, id, key
107
125
  catalog_exists? catalog
108
- if @report.at_css("#{catalog}").at("//*[@id='#{id}']")
109
- @report.at_css("#{catalog}").at("//*[@id='#{id}']")["#{key}"]
126
+ if @report.at_css("#{catalog}").at("[@id='#{id}']")
127
+ @report.at_css("#{catalog}").at("[@id='#{id}']")["#{key}"]
110
128
  else
111
129
  return false
112
130
  end
data/qsar-report.gemspec CHANGED
@@ -3,7 +3,7 @@
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "qsar-report"
5
5
  s.version = File.read("./VERSION")
6
- s.date = "2016-08-19"
6
+ s.date = "2016-09-14"
7
7
  s.authors = ["Micha Rautenberg"]
8
8
  s.email = ["rautenberg@in-silico.ch"]
9
9
  s.homepage = "http://github.com/opentox/qsar-report"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qsar-report
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Micha Rautenberg
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-19 00:00:00.000000000 Z
11
+ date: 2016-09-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri