Class: ParseFasta::SeqFile
- Inherits:
-
Object
- Object
- ParseFasta::SeqFile
- Defined in:
- lib/parse_fasta/seq_file.rb
Instance Attribute Summary collapse
-
#type ⇒ Symbol
The type of the SeqFile (:fasta or :fastq).
Class Method Summary collapse
-
.open(fname) ⇒ SeqFile
An alias for SeqFile.new.
Instance Method Summary collapse
-
#each_record {|record| ... } ⇒ Object
Analagous to IO#each_line, SeqFile#each_record is used to go through a fastA or fastQ file record by record.
-
#initialize(fname) ⇒ SeqFile
constructor
A new instance of SeqFile.
Constructor Details
#initialize(fname) ⇒ SeqFile
Returns a new instance of SeqFile.
34 35 36 37 38 39 |
# File 'lib/parse_fasta/seq_file.rb', line 34 def initialize fname type = check_file fname @fname = fname @type = type end |
Instance Attribute Details
#type ⇒ Symbol
25 26 27 |
# File 'lib/parse_fasta/seq_file.rb', line 25 def type @type end |
Class Method Details
.open(fname) ⇒ SeqFile
An alias for SeqFile.new
44 45 46 |
# File 'lib/parse_fasta/seq_file.rb', line 44 def self.open fname self.new fname end |
Instance Method Details
#each_record {|record| ... } ⇒ Object
Analagous to IO#each_line, SeqFile#each_record is used to go through a fastA or fastQ file record by record. It will accept gzipped files as well.
If the input is a fastA file, then the record that is yielded will have the desc and qual instance variables be nil. If it is a fastQ record then those instance variables will not be nil.
73 74 75 76 77 78 79 80 81 |
# File 'lib/parse_fasta/seq_file.rb', line 73 def each_record &b line_parser = "parse_#{@type}_lines" if gzipped? @fname each_record_gzipped line_parser, &b else each_record_non_gzipped line_parser, &b end end |