Sha256: d8a1f22f0036a1f6e4a2a93d312ea38f35d9327c1e69457386550fdfd410a80a

Contents?: true

Size: 1.84 KB

Versions: 2

Compression:

Stored size: 1.84 KB

Contents

require 'spec_helper'
require 'quorum/sequence'

include Quorum::Sequence

describe "Quorum::Sequence" do
  describe "#create_hash" do
    it "creates a MD5.hexdigest of a sequence" do
      sequence = File.open(
        File.expand_path("../../data/nucl_prot_seqs.txt", __FILE__)
      ).read
      create_hash(sequence).should_not be_nil
    end
  end

  describe "#write_input_sequence_to_file" do
    it "writes valid FASTA input sequence to file" do
      sequence = File.open(
        File.expand_path("../../data/nucl_prot_seqs.txt", __FILE__)
      ).read
      dir  = File.join(::Rails.root.to_s, "log")
      hash = create_hash(sequence)
      write_input_sequence_to_file(dir, hash, sequence)

      File.size(
        File.join(dir, hash + ".seq")
      ).should be > 0

      File.size(
        File.join(dir, hash + ".fa")
      ).should be > 0

      `rm #{File.join(dir, hash + "*")}`
    end

    it "raises an exception if seqret's exit status is > 0" do
      sequence = File.open(
        File.expand_path("../../data/seqs_not_fa.txt", __FILE__)
      ).read
      dir  = File.join(::Rails.root.to_s, "log")
      hash = create_hash(sequence)
      lambda {
        write_input_sequence_to_file(dir, hash, sequence)
      }.should raise_error
      `rm #{File.join(dir, hash + "*")}`
    end
  end

  describe "#discover_input_sequence_type" do
    it "should return 'nucleic_acid' when fed nucleic acid sequences" do
      sequence = File.open(
        File.expand_path("../../data/nucl_seqs.txt", __FILE__)
      ).read
      discover_input_sequence_type(sequence).should eq("nucleic_acid")
    end

    it "should return 'amino_acid' when fed amino acid sequences" do
      sequence = File.open(
        File.expand_path("../../data/prot_seqs.txt", __FILE__)
      ).read
      discover_input_sequence_type(sequence).should eq("amino_acid")
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
quorum-0.3.2 spec/quorum/quorum_sequence_spec.rb
quorum-0.3.1 spec/quorum/quorum_sequence_spec.rb