spec/cli_spec.rb in lederhosen-2.0.8 vs spec/cli_spec.rb in lederhosen-3.1.0

- old
+ new

@@ -1,8 +1,8 @@ require 'spec_helper' -describe Lederhosen::CLI do +describe Lederhosen::CLI, :requires_usearch => true do it 'should have an executable' do `./bin/lederhosen` $?.success?.should be_true end @@ -37,66 +37,46 @@ .select { |x| x =~ /^N/ }\ .size unclassified_reads = File.readlines("#{$test_dir}/unclassified.fasta")\ .select { |x| x =~ /^>/ }\ .size - + unclassified_results.should == unclassified_reads end - + it 'can separate unclassified reads from usearch output using strict pairing' do `./bin/lederhosen separate_unclassified --strict=genus --uc-file=spec/data/test.uc --reads=spec/data/trimmed/ILT_L_9_B_001.fasta --output=#{$test_dir}/unclassified.strict_genus.fasta` $?.success?.should be_true File.readlines("#{$test_dir}/unclassified.strict_genus.fasta")\ .select { |x| x =~ /^>/ }\ .size.should be_even end it 'can create taxonomy count tables' do - `./bin/lederhosen count_taxonomies --input=spec/data/test.uc --output=#{$test_dir}/taxonomy_count.txt` + `./bin/lederhosen count_taxonomies --input=spec/data/test.uc --output=#{$test_dir}/taxonomy_count.tax` $?.success?.should be_true - File.exists?(File.join($test_dir, 'taxonomy_count.txt')).should be_true + File.exists?(File.join($test_dir, 'taxonomy_count.tax')).should be_true end it 'generates taxonomy tables w/ comma-free taxonomic descriptions' do - File.readlines(File.join($test_dir, 'taxonomy_count.txt'))\ + File.readlines(File.join($test_dir, 'taxonomy_count.tax'))\ .map(&:strip)\ .map { |x| x.count(',') }\ .uniq\ .should == [1] end - %w{domain phylum class order family genus species}.each do |level| - it "generates taxonomy tables only counting pairs that agree at level: #{level}" do - `./bin/lederhosen count_taxonomies --input=spec/data/test.uc --output=#{$test_dir}/taxonomy_count.strict.#{level}.txt --strict=#{level}` - $?.success?.should be_true - - lines = File.readlines(File.join($test_dir, "taxonomy_count.strict.#{level}.txt")) - - # make sure total number of reads is even - # requires that there should be an odd number if classification is not strict - lines.select { |x| !(x =~ /^#/) }\ - .map(&:strip)\ - .map { |x| x.split(',') }\ - .map(&:last)\ - .map(&:to_i)\ - .inject(:+).should be_even - end + it 'can create OTU abundance matrices' do + `./bin/lederhosen otu_table --files=#{$test_dir}/taxonomy_count.tax --output=#{$test_dir}/otus.genus.csv --level=genus` + $?.success?.should be_true end - %w{domain phylum class order family genus species}.each do |level| - it "should create OTU abundance matrices from taxonomy count tables at level: #{level}" do - `./bin/lederhosen otu_table --files=#{$test_dir}/taxonomy_count.strict.*.txt --level=#{level} --output=#{$test_dir}/otus_genus.strict.csv` - $?.success?.should be_true - end - end - it 'should filter OTU abundance matrices' do # TODO # filtering should move filtered reads to 'unclassified_reads' so that we maintain # our knowledge of depth of coverage throughout # this makes normalization better later. - `./bin/lederhosen otu_filter --input=#{$test_dir}/otus_genus.strict.csv --output=#{$test_dir}/otu_table.filtered.csv --reads 1 --samples 1` + `./bin/lederhosen otu_filter --input=#{$test_dir}/otus.genus.csv --output=#{$test_dir}/otus_genus.filtered.csv --reads 1 --samples 1` $?.success?.should be_true end it 'should split a fasta file into smaller fasta files (optionally gzipped)' do `./bin/lederhosen split_fasta --input=spec/data/trimmed/ILT_L_9_B_001.fasta --out-dir=#{$test_dir}/split/ --gzip true -n 100`