<commit_before>require 'spec_helper'

require 'mspire/obo'


describe Mspire::Obo do 

  let(:bases) { %w(psi-ms unit imagingMS PSI-MOD quality) }
  let(:filename) { Hash[bases.map {|base| [base, Mspire::Obo::DIR + "/#{base}.obo"] }] }

  let(:normal) { /\A[\d\.]{5,10}\Z/ }# "0.9.1" or "0.91.132"
  let(:date) { /\A[\d:]{8,15}\Z/ } # "09:04:2014"

  describe 'the Mspire::Obo class' do
    specify '#version(filename) returns the version' do
      expect(Mspire::Obo.version(filename['psi-ms'])).to match(normal)
    end

    specify '#available returns an informative hash for each obo' do
      hashes = Mspire::Obo.available
      hashes.each {|hash| expect(hash.keys.sort).to eq [:full_name, :uri, :namespace, :path, :version, :key].sort }
      ms_hash = hashes.find {|hash| hash[:namespace] == 'MS' }
      expect(ms_hash[:full_name].split(' ').first).to eq('Proteomics')
      expect(ms_hash[:uri]).to match(/psidev.*psi-ms.obo/)
      expect(ms_hash[:namespace]).to eq "MS"
      expect(ms_hash[:path]).to match(/.+obo\/psi-ms.obo/)
      expect(ms_hash[:version]).to match normal
      expect(ms_hash[:key]).to eq :ms
    end

    specify '#[symbol] loads an obo with a simple key symbol' do
      obo = Mspire::Obo[:ms]
      expect(obo.class).to eq Mspire::Obo
      expect(obo.full_name.split(' ').first).to eq('Proteomics')
      expect(obo.version).to match normal
      expect(obo.uri).to match(/psidev.*psi-ms.obo/)
      expect(obo.stanzas.size).to be > 2000
    end
    specify '#[symbol, false] loads an obo (no file loaded) with a simple key symbol' do<commit_msg>ensuring spec picks up new unimod obo<commit_after>require 'spec_helper'
require 'mspire/obo'

describe Mspire::Obo do 

  let(:bases) { %w(psi-ms unit imagingMS PSI-MOD quality) }
  let(:filename) { Hash[bases.map {|base| [base, Mspire::Obo::DIR + "/#{base}.obo"] }] }

  let(:normal) { /\A[\d\.]{5,10}\Z/ }# "0.9.1" or "0.91.132"
  let(:date) { /\A[\d:]{8,15}\Z/ } # "09:04:2014"

  describe 'the Mspire::Obo class' do
    specify '#version(filename) returns the version' do
      expect(Mspire::Obo.version(filename['psi-ms'])).to match(normal)
    end

    specify '#available returns an informative hash for each obo' do
      hashes = Mspire::Obo.available
      hashes.each {|hash| expect(hash.keys.sort).to eq [:full_name, :uri, :namespace, :path, :version, :key].sort }
      expect( hashes.map {|hash| hash[:key] }.sort ).to eq [:mod, :ims, :ms, :pato, :unimod, :uo].sort
      ms_hash = hashes.find {|hash| hash[:namespace] == 'MS' }
      expect(ms_hash[:full_name].split(' ').first).to eq('Proteomics')
      expect(ms_hash[:uri]).to match(/psidev.*psi-ms.obo/)
      expect(ms_hash[:namespace]).to eq "MS"
      expect(ms_hash[:path]).to match(/.+obo\/psi-ms.obo/)
      expect(ms_hash[:version]).to match normal
      expect(ms_hash[:key]).to eq :ms
    end

    specify '#[symbol] loads an obo with a simple key symbol' do
      obo = Mspire::Obo[:ms]
      expect(obo.class).to eq Mspire::Obo
      expect(obo.full_name.split(' ').first).to eq('Proteomics')
      expect(obo.version).to match normal
      expect(obo.uri).to match(/psidev.*psi-ms.obo/)
      expect(obo.stanzas.size).to be > 2000
    end
    specify '#[symbol, false] loads an obo (no file loaded) with a simple key symbol' do
{'fraction_non_alphanumeric': 0.18391502276176025, 'fraction_numerical': 0.01638846737481032, 'mean_word_length': 3.4301075268817205, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '886580', 'n_tokens_mistral': 1274, 'n_tokens_neox': 1198, 'n_words': 274}