From 59509099257225b068a13626d3a42eac2f4244ab Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Tue, 13 Oct 2020 11:25:51 +0200 Subject: mutagenicity downloads moved, PaDEL metadata --- lib/compound.rb | 11 +++++------ lib/dataset.rb | 24 ------------------------ 2 files changed, 5 insertions(+), 30 deletions(-) (limited to 'lib') diff --git a/lib/compound.rb b/lib/compound.rb index 4436e9d..4f0a924 100644 --- a/lib/compound.rb +++ b/lib/compound.rb @@ -111,16 +111,16 @@ class Compound # @return [Lazar::Compound] def self.from_smiles smiles return nil if smiles.match(/\s/) # spaces seem to confuse obconversion and may lead to invalid smiles - @smiles = obconversion(smiles,"smi","can") # test if SMILES is correct and return canonical smiles (for compound comparisons) - @smiles.empty? ? nil : @smiles + smiles = obconversion(smiles,"smi","can") # test if SMILES is correct and return canonical smiles (for compound comparisons) + smiles.empty? ? nil : self.new(smiles) end # Create a compound from InChI string # @param [String] InChI # @return [OpenTox::Compound] def self.from_inchi inchi - @smiles = obconversion(inchi,"inchi","can") - @smiles.empty? ? nil : @smiles + smiles = obconversion(inchi,"inchi","can") + smiles.empty? ? nil : self.new(smiles) end # Create a compound from SDF @@ -137,7 +137,7 @@ class Compound # @param [String] name, can be also an InChI/InChiKey, CAS number, etc # @return [OpenTox::Compound] def self.from_name name - Compound.from_smiles RestClientWrapper.get(File.join(PUBCHEM_URI,"compound","name",URI.escape(name),"property","CanonicalSMILES","TXT")).chomp + self.from_smiles RestClientWrapper.get(File.join(PUBCHEM_URI,"compound","name",URI.escape(name),"property","CanonicalSMILES","TXT")).chomp end # Get InChI @@ -224,7 +224,6 @@ class Compound builder.build(obmol) sdf = obconversion.write_string(obmol) -print sdf if sdf.match(/.nan/) #warn "3D generation failed for compound #{identifier}, trying to calculate 2D structure" diff --git a/lib/dataset.rb b/lib/dataset.rb index 87e7fef..e30f000 100644 --- a/lib/dataset.rb +++ b/lib/dataset.rb @@ -114,30 +114,6 @@ end dataset end - - # Convert dataset to SDF format - # @return [String] SDF string - def to_sdf - - export_features = merged_features - export_features = transformed_bioactivity_features if export_features.empty? - export_features = bioactivity_features if export_features.empty? - export_feature = export_features.first - - sdf = "" - compounds.each do |compound| - sdf_lines = compound.sdf.sub(/\$\$\$\$\n/,"").split("\n") - sdf_lines[0] = compound.smiles - sdf += sdf_lines.join("\n") - sdf += "\n> <#{export_feature.name}>\n" - sdf += values(compound,export_feature).uniq.join "," - sdf += "\n" - sdf += "\n$$$$\n" - end - sdf - end - - # Merge an array of datasets # @param [Array] datasets Datasets to be merged # @param [Array] features Features to be merged (same size as datasets) -- cgit v1.2.3