Class: Bio::Faster

Inherits:
Object
  • Object
show all
Extended by:
FFI::Library
Defined in:
lib/bio/faster.rb,
lib/bio/faster/library.rb

Defined Under Namespace

Classes: FastQRecord, Library

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file) ⇒ Faster

Returns a new instance of Faster.



16
17
18
# File 'lib/bio/faster.rb', line 16

def initialize(file)
    self.file = file
end

Instance Attribute Details

#encodingObject

Returns the value of attribute encoding.



15
16
17
# File 'lib/bio/faster.rb', line 15

def encoding
  @encoding
end

#fileObject

Returns the value of attribute file.



14
15
16
# File 'lib/bio/faster.rb', line 14

def file
  @file
end

Instance Method Details

#each_record(args = {:quality => :sanger}, &block) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/bio/faster.rb', line 34

def each_record(args = {:quality => :sanger}, &block)
    if self.file == :stdin
      self.file = "stdin"
    elsif !File.exists? self.file
      raise ArgumentError, "File #{self.file} does not exist"
    end
    record = FastQRecord.new
    record[:filename] = FFI::MemoryPointer.from_string self.file
result = nil
    case args[:quality]
     	when :sanger
		scale_factor = 33	
		result = parse_fastq_with_quality_conversion(record, scale_factor, &block)
     	when :solexa 
		scale_factor = 64
		result = parse_fastq_with_quality_conversion(record, scale_factor, &block)	
	when :raw
		scale_factor = 0
		result = parse_fastq(record, scale_factor, &block)	
end

case result
      when -1 then raise RuntimeError, "Bad formatted FastQ file!"
      when -2 then raise RuntimeError, "Sequence or quality is truncated!"
    end


end