Class: Bio::Freebayes

Inherits:
Object
  • Object
show all
Defined in:
lib/bio/freebayes.rb,
lib/bio/freebayes/version.rb

Constant Summary collapse

VERSION =
"0.1.6"
EXTVERSION =
"0.9.20"

Instance Method Summary collapse

Constructor Details

#initialize(path = nil) ⇒ Freebayes

instantiate Freebayes command tools



8
9
10
11
12
# File 'lib/bio/freebayes.rb', line 8

def initialize(path = nil)
	@filter = nil
	@eval = nil
	@path = path || File.join(File.expand_path(File.dirname(__FILE__)), 'freebayes', 'external', 'freebayes')
end

Instance Method Details

#helpObject



59
60
61
# File 'lib/bio/freebayes.rb', line 59

def help
	`#{@path} -h`
end

#run(fasta_reference, bam, *options) ⇒ String

run freebayes tools for command and all options please go to github.com/ekg/freebayes

Parameters:

  • fasta_reference (String)

    path of the reference fasta file

  • bam (String)

    path of the alignment file in bam format

  • options (Array)

    of freebayes command

Returns:

  • (String)

    A VCF string



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/bio/freebayes.rb', line 21

def run(fasta_reference, bam, *options)
	result = `#{@path} #{options.flatten.join(' ')} --fasta-reference #{fasta_reference} #{bam}`
	if @filter != nil || @eval != nil || @filter != '' || @eval != ''
		Open3.popen2("bio-vcf #{@filter != nil && !@filter.empty? ? "--filter '#{@filter}' " : ''}#{@eval != nil && !@eval.empty? ? "--eval '#{@eval}' " : ''}") {|stdin, stdout, wthr|
			stdin.print result
			stdin.close
			return stdout.gets
		}
	else 
		return result
	end
end

#vcfeval(eval) ⇒ Freebayes

set command for the eval option of bio-vcf more details please go to github.com/pjotrp/bioruby-vcf the chaning have to end with run

Parameters:

  • eval (String)

    a VCF filter for bio-vcf

Returns:

  • (Freebayes)

    return freebayes object for chaining



51
52
53
54
# File 'lib/bio/freebayes.rb', line 51

def vcfeval(eval)
	@eval = eval
	return self
end

#vcffilter(filter) ⇒ Freebayes

set bio-vcf Filter for details please go to github.com/pjotrp/bioruby-vcf the chaning have to end with run

Parameters:

  • filter (String)

    a VCF filter for bio-vcf

Returns:

  • (Freebayes)

    return freebayes object for chaining



40
41
42
43
# File 'lib/bio/freebayes.rb', line 40

def vcffilter(filter)
	@filter = filter
	return self
end