Sha256: db3197ff245d40231fa309097f54098b037f4f3825b6fd731e203b6653946375

Contents?: true

Size: 1.52 KB

Versions: 6

Compression:

Stored size: 1.52 KB

Contents

# Copyright 2014 Ryan Moore
# Contact: moorer@udel.edu
#
# This file is part of parse_fasta.
#
# parse_fasta is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# parse_fasta is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with parse_fasta.  If not, see <http://www.gnu.org/licenses/>.

require 'spec_helper'

describe FastaFile do
  describe "#each_record" do

    let(:fname) { "#{File.dirname(__FILE__)}/../../test_files/test.fa" }
    it "yields a block with header and sequence for each record in a fasta file" do
      seqs = []
      FastaFile.open(fname, 'r').each_record do |header, sequence|
        seqs << [header, sequence]
      end
      
      expect(seqs).to eq([["seq1 is fun", "AACTGGend"],
                          ["seq2", "AATCCTGend"],
                          ["seq3", "yyyyyyyyyyyyyyyend"]])

    end

    it "passes header of type string as first parameter" do
      sequence_class = nil
      FastaFile.open(fname, 'r').each_record do |header, sequence|
        sequence_class = sequence.class
        break
      end
      expect(sequence_class).to be Sequence
    end      
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
parse_fasta-1.2.0 spec/lib/fasta_file_spec.rb
parse_fasta-1.1.2 spec/lib/fasta_file_spec.rb
parse_fasta-1.1.1 spec/lib/fasta_file_spec.rb
parse_fasta-1.1.0 spec/lib/fasta_file_spec.rb
parse_fasta-1.0.1 spec/lib/fasta_file_spec.rb
parse_fasta-1.0.0 spec/lib/fasta_file_spec.rb