SpectrumHash

A library for creating a Splash keys following the splash definition. Splash stands for the spectra hash code and is an unique identifier independent of acquisition or processing. It basically tries to ensure that you can easily tell if two spectra are identical, similar or very different. Based on several criteria.

This library simply wraps the REST API available at http://splash.fiehnlab.ucdavis.edu/ It also has some convenient methods to work with splashes.

Paper in progress...

Installation

Add this line to your application's Gemfile:

gem 'spectrum_hash'

And then execute:

$ bundle

Or install it yourself as:

$ gem install spectrum_hash

Usage

Create a splash from a peak list.

require 'spectrum_hash'

# List of m/z and intensity for each peak
spectrum = [
  [  41.982,  4383598.000],
  [  56.450,   867285.813],
  [  69.408,  1181789.750],
  [  83.625,  1009049.375],
  [ 123.006,  1119260.125],
  [ 538.356,   421962.563],
  [1026.834,  1193619.381]
]

SpectrumHash.from_peaks(spectrum).splash
# => "splash10-0006-9100000000-b0cf38693934211e4e35"

Create a splash from a tab delimited list of peaks and strings.

spectrum = "41.982  4383598.000\n56.450  867285.813\n69.408  1181789.750\n83.625  1009049.375\n123.006     1119260.125\n138.356     421962.563\n1026.834 1193619.381\n"

SpectrumHash.from_string(spectrum).splash
# => "splash10-0006-9100000000-b0cf38693934211e4e35"

There are a few convenience methods to get the different components of the splash


splash = SpectrumHash.from_splash_string "splash10-0006-9100000000-b0cf38693934211e4e35"

# print the version number for the splash
splash.version
# => "1"

# get the full version block
splash.version_block
# => "splash10"

# get the top ten block
splash.top_ten_block
# => "0006"

# get the histogram block
splash.histogram_block
# => "9100000000"

# get the hash block
splash.hash_block
# => "b0cf38693934211e4e35"

# get the histogram as a list of integers (handy for comparisons)
splash.histogram_list
# => [35, 4, 0, 17, 0, 1, 0, 0, 0, 0]

Get the manhattan distance between the histogram blocks of two splashes

splash1.distance_to splash2
# => 17

Contributing

  1. Fork it ( https://github.com/[my-github-username]/spectrum_hash/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request