Class: Bio::BFRTools::Container

Inherits:
Object
  • Object
show all
Defined in:
lib/bio/BFRTools.rb

Direct Known Subclasses

BFRContainer

Constant Summary collapse

BASES =
[:A, :C, :G, :T]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#bulk_1_nameObject (readonly)

Returns the value of attribute bulk_1_name.



29
30
31
# File 'lib/bio/BFRTools.rb', line 29

def bulk_1_name
  @bulk_1_name
end

#bulk_1_samObject (readonly)

Returns the value of attribute bulk_1_sam.



28
29
30
# File 'lib/bio/BFRTools.rb', line 28

def bulk_1_sam
  @bulk_1_sam
end

#bulk_2_nameObject (readonly)

Returns the value of attribute bulk_2_name.



29
30
31
# File 'lib/bio/BFRTools.rb', line 29

def bulk_2_name
  @bulk_2_name
end

#bulk_2_samObject (readonly)

Returns the value of attribute bulk_2_sam.



28
29
30
# File 'lib/bio/BFRTools.rb', line 28

def bulk_2_sam
  @bulk_2_sam
end

#parental_1_nameObject (readonly)

Returns the value of attribute parental_1_name.



29
30
31
# File 'lib/bio/BFRTools.rb', line 29

def parental_1_name
  @parental_1_name
end

#parental_1_samObject (readonly)

Returns the value of attribute parental_1_sam.



28
29
30
# File 'lib/bio/BFRTools.rb', line 28

def parental_1_sam
  @parental_1_sam
end

#parental_2_nameObject (readonly)

Returns the value of attribute parental_2_name.



29
30
31
# File 'lib/bio/BFRTools.rb', line 29

def parental_2_name
  @parental_2_name
end

#parental_2_samObject (readonly)

Returns the value of attribute parental_2_sam.



28
29
30
# File 'lib/bio/BFRTools.rb', line 28

def parental_2_sam
  @parental_2_sam
end

#processed_regionsObject (readonly)

Returns the value of attribute processed_regions.



28
29
30
# File 'lib/bio/BFRTools.rb', line 28

def processed_regions
  @processed_regions
end

#putative_snpsObject (readonly)

Returns the value of attribute putative_snps.



28
29
30
# File 'lib/bio/BFRTools.rb', line 28

def putative_snps
  @putative_snps
end

#reference_dbObject (readonly)

Returns the value of attribute reference_db.



29
30
31
# File 'lib/bio/BFRTools.rb', line 29

def reference_db
  @reference_db
end

#total_lengthObject (readonly)

Returns the value of attribute total_length.



28
29
30
# File 'lib/bio/BFRTools.rb', line 28

def total_length
  @total_length
end

Class Method Details

.snps_between(seq1, seq2) ⇒ Object



91
92
93
94
95
96
97
# File 'lib/bio/BFRTools.rb', line 91

def self.snps_between(seq1, seq2)
  snps=0
  for i in (0..seq1.size)
    snps += 1 if seq1[i] != seq2[i]
  end
  snps
end

Instance Method Details

#bulk_1(opts) ⇒ Object

Sets the sorted BAM file of the first bulk

Raises:



69
70
71
72
73
74
75
76
77
# File 'lib/bio/BFRTools.rb', line 69

def bulk_1(opts)
  raise BFRToolsException.new("Missing path for bulk 1") if opts[:path] == nil
  path = Pathname.new(opts[:path])
  raise BFRToolsException.new("Unable to open #{path}") unless path.readable? or path.directory?        

  @bulk_1_name =  opts[:name] ? opts[:name] : path.basename(".bam").to_s
  @bulk_1_sam =  Bio::DB::Sam.new({:fasta=>@reference_path, :bam=>path.realpath.to_s})
  @bulk_1_path = path
end

#bulk_2(opts) ⇒ Object

Sets the sorted BAM file of the second bulk

Raises:



80
81
82
83
84
85
86
87
88
# File 'lib/bio/BFRTools.rb', line 80

def bulk_2(opts)
  raise BFRToolsException.new("Missing path for bulk 2") if opts[:path] == nil
  path = Pathname.new(opts[:path])
  raise BFRToolsException.new("Unable to open #{path}") unless path.readable? or path.directory?        

  @bulk_2_name =  opts[:name] ? opts[:name] : path.basename(".bam").to_s
  @bulk_2_sam =  Bio::DB::Sam.new({:fasta=>@reference_path, :bam=>path.realpath.to_s})
  @bulk_2_path = path
end

#parental_1(opts) ⇒ Object

Sets the sorted BAM file of the first parental It accepts the following arguments :name=>A name for thie parental 1 (optional). If not provided, :path=>

Raises:



46
47
48
49
50
51
52
53
54
55
# File 'lib/bio/BFRTools.rb', line 46

def parental_1(opts)
  raise BFRToolsException.new("Missing path for parental 1") if opts[:path] == nil
  path = Pathname.new(opts[:path])
  raise BFRToolsException.new("Unable to open #{path}") unless path.readable? or path.directory?        

  @parental_1_name = opts[:name] ? opts[:name] : path.basename(".bam").to_s
  @parental_1_sam =  Bio::DB::Sam.new({:fasta=>@reference_path, :bam=>path.realpath.to_s})
  @parental_1_path = path

end

#parental_2(opts) ⇒ Object

Sets the sorted BAM file of the second parental

Raises:



58
59
60
61
62
63
64
65
66
# File 'lib/bio/BFRTools.rb', line 58

def parental_2(opts)
  raise BFRToolsException.new("Missing path for parental 2") if opts[:path] == nil
  path = Pathname.new(opts[:path])
  raise BFRToolsException.new("Unable to open #{path}") unless path.readable? or path.directory?        

  @parental_2_name = @name = opts[:name] ? opts[:name] : path.basename(".bam").to_s
  @parental_2_sam =  Bio::DB::Sam.new({:fasta=>@reference_path, :bam=>path.realpath.to_s})
  @parental_2_path = path
end

#reference(path) ⇒ Object

Sets the reference file



33
34
35
36
# File 'lib/bio/BFRTools.rb', line 33

def reference(path)
  @reference_db = Bio::DB::Fasta::FastaFile.new({:fasta=>path})
  @reference_path = path
end

#reference_sequence(region) ⇒ Object



38
39
40
# File 'lib/bio/BFRTools.rb', line 38

def reference_sequence(region)
  @reference_db.fetch_sequence(region)
end