Class: Bio::Velvet::Underground::BinarySequenceStore

Inherits:
Object
  • Object
show all
Defined in:
lib/bio-velvet_underground/binary_sequence_store.rb

Instance Method Summary collapse

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.

Returns:

  • (Boolean)


29
30
31
32
33
34
# File 'lib/bio-velvet_underground/binary_sequence_store.rb', line 29

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

#lengthObject

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

#pair_id(sequence_id) ⇒ Object

Returns the ID of the given sequence_id’s pair



37
38
39
40
41
42
43
# File 'lib/bio-velvet_underground/binary_sequence_store.rb', line 37

def pair_id(sequence_id)
  if is_second_in_pair?(sequence_id)
    sequence_id-1
  else
    sequence_id+1
  end
end