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, args = {}) ⇒ 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, args = {}) ⇒ SeqFile
constructor
A new instance of SeqFile.
Constructor Details
#initialize(fname, args = {}) ⇒ SeqFile
Returns a new instance of SeqFile.
19 20 21 22 23 24 25 |
# File 'lib/parse_fasta/seq_file.rb', line 19 def initialize fname, args = {} type = check_file fname @check_fasta_seq = args.fetch :check_fasta_seq, true @fname = fname @type = type end |
Instance Attribute Details
#type ⇒ Symbol
Returns the type of the SeqFile (:fasta or :fastq).
7 8 9 |
# File 'lib/parse_fasta/seq_file.rb', line 7 def type @type end |
Class Method Details
.open(fname, args = {}) ⇒ SeqFile
An alias for SeqFile.new
30 31 32 |
# File 'lib/parse_fasta/seq_file.rb', line 30 def self.open fname, args = {} self.new fname, args 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.
60 61 62 63 64 65 66 67 68 |
# File 'lib/parse_fasta/seq_file.rb', line 60 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 |