Sha256: db77b759d303bb0a06a0fb89c9124f945ddce359c097377c3008c0b2739490cf

Contents?: true

Size: 1.87 KB

Versions: 2

Compression:

Stored size: 1.87 KB

Contents

require 'snp-search'
require 'snp_db_connection'
require 'snp_db_models'
require 'snp_db_schema'
require 'slop'



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

  on :V, :verbose, 'Enable verbose mode'
  on :n, :name=, 'Name of database', true 
  on :r, :reference_file=, 'Path for the reference database, in gbk or embl file format'
  on :v, :vcf_file=, 'Path for the .vcf file', true
  on :s, :strain, 'Path for the list of strains text file', true
  on :c, :cuttoff_snp=, 'cuttoff for SNP quality' 
  on :t, :cuttoff_genotype=, 'cuttoff for genotype quality'
  on_empty do
    puts help
  end
end

opts.parse

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)

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
snp-search-0.4.0 bin/snp-search
snp-search-0.3.0 bin/snp-search