<commit_before>require 'genome/online_updater'

module Genome; module Importers; module DrugBank;
  class NewDrugBank < Genome::OnlineUpdater
    attr_reader :file_path, :source
    def initialize(file_path)
      @file_path = file_path
    end

    def import
      remove_existing_source
      create_source
      import_claims
    end

    def get_version
      File.open('lib/genome/updaters/data/version').readlines.each do |line|
        source, version = line.split("\t")
        if source == 'DrugBank'
          return version.strip
        end
      end
      return nil
    end

    private

    DELIMITER = ';'

    def remove_existing_source
      Utils::Database.delete_source('DrugBank')
    end

    def create_source
      @source = DataModel::Source.where(
        base_url: 'http://www.drugbank.ca',
        site_url: 'http://www.drugbank.ca/',
        citation: "DrugBank 4.0: shedding new light on drug metabolism. <NAME>, <NAME>, <NAME>, <NAME>, <NAME>, <NAME>, <NAME>, <NAME>, <NAME>, <NAME>, <NAME>, <NAME>, <NAME>, <NAME>, <NAME>, <NAME>, <NAME>, Wishart DS.Nucleic Acids Res. 2014 Jan 1;42(1):D1091-7. PubMed ID: 24203711",
        source_db_version: get_version,<commit_msg>Fix DrugBank importer version path<commit_after>require 'genome/online_updater'

module Genome; module Importers; module DrugBank;
  class NewDrugBank < Genome::OnlineUpdater
    attr_reader :file_path, :source
    def initialize(file_path)
      @file_path = file_path
    end

    def import
      remove_existing_source
      create_source
      import_claims
    end

    def get_version
      File.open('tmp/version').readlines.each do |line|
        source, version = line.split("\t")
        if source == 'DrugBank'
          return version.strip
        end
      end
      return nil
    end

    private

    DELIMITER = ';'

    def remove_existing_source
      Utils::Database.delete_source('DrugBank')
    end

    def create_source
      @source = DataModel::Source.where(
        base_url: 'http://www.drugbank.ca',
        site_url: 'http://www.drugbank.ca/',
        citation: "DrugBank 4.0: shedding new light on drug metabolism. <NAME>, <NAME>, <NAME>, <NAME>, <NAME>, <NAME>, <NAME>, <NAME>, <NAME>, <NAME>, <NAME>, <NAME>, <NAME>, <NAME>, <NAME>, <NAME>, <NAME>, <NAME>.Nucleic Acids Res. 2014 Jan 1;42(1):D1091-7. PubMed ID: 24203711",
        source_db_version: get_version,
{'fraction_non_alphanumeric': 0.12468723936613844, 'fraction_numerical': 0.019182652210175146, 'mean_word_length': 2.9135399673735725, 'pattern_counts': {'":': 0, '<': 40, '<?xml version=': 0, '>': 38, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4661741', 'n_tokens_mistral': 826, 'n_tokens_neox': 755, 'n_words': 192}