Sha256: 1309512018332560d699ec4be9673e37336200e6f90806118079a72797ddcbcb

Contents?: true

Size: 823 Bytes

Versions: 6

Compression:

Stored size: 823 Bytes

Contents

module OpenTox
  module Algorithm
    class Neighbor

      def self.fingerprint_similarity compound, params={}
        compound.neighbors params[:min_sim]
      end

      def self.fminer_similarity compound, params
        feature_dataset = Dataset.find params[:feature_dataset_id]
        query_fingerprint = Algorithm::Descriptor.smarts_match(compound, feature_dataset.features)
        neighbors = []

        # find neighbors
        feature_dataset.data_entries.each_with_index do |fingerprint, i|
          sim = Algorithm::Similarity.tanimoto fingerprint, query_fingerprint
          if sim > params[:min_sim]
            neighbors << [feature_dataset.compound_ids[i],sim] # use compound_ids, instantiation of Compounds is too time consuming
          end
        end
        neighbors
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
lazar-0.0.7 lib/neighbor.rb
lazar-0.0.6 lib/neighbor.rb
lazar-0.0.5 lib/neighbor.rb
lazar-0.0.4 lib/neighbor.rb
lazar-0.0.3 lib/neighbor.rb
lazar-0.0.1 lib/neighbor.rb