Class: Sam
Defined Under Namespace
Instance Attribute Summary collapse
-
#header ⇒ Object
Returns the value of attribute header.
-
#mates ⇒ Object
readonly
Returns the value of attribute mates.
-
#reads ⇒ Object
readonly
Returns the value of attribute reads.
Class Method Summary collapse
Instance Method Summary collapse
- #add_mate(mate, record) ⇒ Object
- #each ⇒ Object
-
#initialize ⇒ Sam
constructor
A new instance of Sam.
- #inspect ⇒ Object
- #output(f) ⇒ Object
Methods included from Printer
Constructor Details
#initialize ⇒ Sam
Returns a new instance of Sam.
156 157 158 159 |
# File 'lib/sam.rb', line 156 def initialize @reads = [] @mates = {} end |
Instance Attribute Details
#header ⇒ Object
Returns the value of attribute header.
155 156 157 |
# File 'lib/sam.rb', line 155 def header @header end |
#mates ⇒ Object (readonly)
Returns the value of attribute mates.
154 155 156 |
# File 'lib/sam.rb', line 154 def mates @mates end |
#reads ⇒ Object (readonly)
Returns the value of attribute reads.
154 155 156 |
# File 'lib/sam.rb', line 154 def reads @reads end |
Class Method Details
.read(file) ⇒ Object
172 173 174 175 176 177 178 179 180 181 182 183 184 |
# File 'lib/sam.rb', line 172 def self.read file sam = self.new header = [] File.foreach(file) do |l| if l =~ /^@/ header.push l next end sam.reads.push Sam::Read.new(sam, l.chomp.split(/\t/,12)) end sam.header = Sam::Header.new(sam, header) sam end |
Instance Method Details
#add_mate(mate, record) ⇒ Object
161 162 163 164 |
# File 'lib/sam.rb', line 161 def add_mate mate, record @mates[mate] ||= [] @mates[mate].push record end |
#each ⇒ Object
166 167 168 169 170 |
# File 'lib/sam.rb', line 166 def each @reads.each do |r| yield r end end |
#inspect ⇒ Object
193 194 195 |
# File 'lib/sam.rb', line 193 def inspect "#<#{self.class.name}:#{object_id} @reads=#{reads.size}>" end |
#output(f) ⇒ Object
186 187 188 189 190 191 |
# File 'lib/sam.rb', line 186 def output f @header.output f @reads.each do |r| r.output f end end |