Class: Bio::Velvet::Underground::BinarySequenceStore
- Inherits:
-
Object
- Object
- Bio::Velvet::Underground::BinarySequenceStore
- Defined in:
- lib/bio-velvet_underground/binary_sequence_store.rb
Instance Method Summary collapse
-
#[](sequence_id) ⇒ Object
Return a sequence from the store given its read ID.
-
#initialize(cny_unified_seq_file) ⇒ BinarySequenceStore
constructor
Parse a CnyUnifiedSeq file in so that sequences can be accessed.
-
#is_second_in_pair?(sequence_id) ⇒ Boolean
Returns true if the sequence ID refers to the second in a pair of sequences.
-
#length ⇒ Object
Number of sequences in this store.
-
#num_paired_end_readsets ⇒ Object
Return the number of libraries used in this sequence store that were paired-end e.g.
-
#pair_id(sequence_id) ⇒ Object
Returns the ID of the given sequence_id’s pair, or nil if it is not a paired sequence.
-
#paired?(sequence_id) ⇒ Boolean
Return true if paired, else false.
Constructor Details
#initialize(cny_unified_seq_file) ⇒ BinarySequenceStore
Parse a CnyUnifiedSeq file in so that sequences can be accessed
4 5 6 7 8 |
# File 'lib/bio-velvet_underground/binary_sequence_store.rb', line 4 def initialize(cny_unified_seq_file) Bio::Velvet::Underground.attach_shared_library readset_pointer = Bio::Velvet::Underground.importCnyReadSet cny_unified_seq_file @readset = Bio::Velvet::Underground::ReadSet.new(readset_pointer) end |
Instance Method Details
#[](sequence_id) ⇒ Object
Return a sequence from the store given its read ID.
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/bio-velvet_underground/binary_sequence_store.rb', line 11 def [](sequence_id) if sequence_id==0 or sequence_id > @readset[:readCount] raise "Invalid sequence_id #{sequence_id}" end pointer = Bio::Velvet::Underground.getTightStringInArray( @readset[:tSequences], sequence_id-1 ) Bio::Velvet::Underground.readTightString pointer end |
#is_second_in_pair?(sequence_id) ⇒ Boolean
Returns true if the sequence ID refers to the second in a pair of sequences.
41 42 43 44 45 46 |
# File 'lib/bio-velvet_underground/binary_sequence_store.rb', line 41 def is_second_in_pair?(sequence_id) if sequence_id==0 or sequence_id > @readset[:readCount] raise "Invalid sequence_id #{sequence_id}" end Bio::Velvet::Underground.isSecondInPair @readset, sequence_id-1 end |
#length ⇒ Object
Number of sequences in this store
23 24 25 |
# File 'lib/bio-velvet_underground/binary_sequence_store.rb', line 23 def length @readset[:readCount] end |
#num_paired_end_readsets ⇒ Object
Return the number of libraries used in this sequence store that were paired-end e.g.
61 62 63 |
# File 'lib/bio-velvet_underground/binary_sequence_store.rb', line 61 def num_paired_end_readsets Bio::Velvet::Underground.pairedCategories(@readset) end |
#pair_id(sequence_id) ⇒ Object
Returns the ID of the given sequence_id’s pair, or nil if it is not a paired sequence
50 51 52 53 54 55 56 57 |
# File 'lib/bio-velvet_underground/binary_sequence_store.rb', line 50 def pair_id(sequence_id) return nil unless paired?(sequence_id) if is_second_in_pair?(sequence_id) sequence_id-1 else sequence_id+1 end end |
#paired?(sequence_id) ⇒ Boolean
Return true if paired, else false
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/bio-velvet_underground/binary_sequence_store.rb', line 28 def paired?(sequence_id) cat = FFI::Pointer.new(:int8, @readset[:categories])[sequence_id-1].read_int8 if cat == 0 return false elsif cat == 1 return true else raise "Unexpected velvet sequence category found: #{cat}" end end |