Sha256: 01d2a50a21253152bf14d45aaaf4b886cb5b0c7df9c369e1d010a324f1d55996

Contents?: true

Size: 1.96 KB

Versions: 4

Compression:

Stored size: 1.96 KB

Contents

require 'snp-search'
require 'snp_db_connection'
require 'snp_db_models'
require 'snp_db_schema'
require 'slop'
gem "slop", "~> 2.4.0"


opts = Slop.new :help do
  banner "ruby snp-search [OPTIONS]"

  on :V, :verbose, 'Enable verbose mode'
  on :n, :name=, 'Name of database', :default => 'snp_db.sqlite3' 
  on :r, :reference_file=, 'Reference genome file, in gbk or embl file format', true
  on :v, :vcf_file=, '.vcf file', true
  on :s, :strain=, 'text file with a list of strains/samples', true
  on :c, :cuttoff_snp=, 'SNP quality cutoff', :default => 90 
  on :t, :cuttoff_genotype=, 'Genotype quality cutoff', :default => 30
   
  on_empty do
    puts help
  end
end
opts.parse


begin
strains = []
  File.read(opts[:strain]).each_line do |line| 
    strains << line.chop
  end
 

# Enter the name of your database 
establish_connection(opts[:name])

# Schema will run here
db_schema

ref = opts[:reference_file]

sequence_format = guess_sequence_format(ref)

      case sequence_format
      when :genbank
        sequence_flatfile = Bio::FlatFile.open(Bio::GenBank,opts[:reference_file]).next_entry
      when :embl
        sequence_flatfile = Bio::FlatFile.open(Bio::EMBL,opts[:reference_file]).next_entry
      else
        puts "All sequence files should be of genbank or embl format"
        exit
      end


# path for vcf file here
vcf_mpileup_file = opts[:vcf_file]


# The populate_strains method populates the strains in the db. It uses the strain names in array.
populate_strains(strains)

# The populate_features_and_annotations method populates the features and annotations.  It uses the embl/gbk file.
populate_features_and_annotations(sequence_flatfile)

#The populate_snps_alleles_genotypes method populates the snps, alleles and genotypes.  It uses the strain names (array) and vcf file.
populate_snps_alleles_genotypes(strains, vcf_mpileup_file, opts[:cuttoff_snp].to_i, opts[:cuttoff_genotype].to_i)

rescue
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
snp-search-0.17.0 bin/snp-search
snp-search-0.16.0 bin/snp-search
snp-search-0.15.0 bin/snp-search
snp-search-0.14.0 bin/snp-search