Class: Bio::Ngs::Illumina::Sample
- Inherits:
-
Meta::Pool
- Object
- Meta::Data
- Meta::Pool
- Bio::Ngs::Illumina::Sample
- Defined in:
- lib/bio/ngs/illumina/sample.rb
Overview
File
Instance Attribute Summary
Attributes inherited from Meta::Pool
Attributes inherited from Meta::Data
Instance Method Summary collapse
- #add_filename(filename) ⇒ Object
-
#filenames_paths ⇒ Object
REMOVE # def get(tag=filtered) @files.get(tag) end.
-
#initialize(name, path, parent = nil) ⇒ Sample
constructor
attr_accessor :name #, :filenames.
- #paired? ⇒ Boolean
- #path ⇒ Object
- #to_json(*a) ⇒ Object
Methods inherited from Meta::Pool
#add, #each, #empty?, #get, #get_by_name, #get_by_tag, #get_by_tag_and_value, #get_by_value, #get_down_to_childer, json_create, #names
Methods included from Enumerable
#average, #sample_variance, #standard_deviation, #sum
Methods inherited from Meta::Data
#==, #[], #has_tag?, #has_value?, json_create, #name, #name=
Constructor Details
#initialize(name, path, parent = nil) ⇒ Sample
attr_accessor :name #, :filenames
31 32 33 34 35 |
# File 'lib/bio/ngs/illumina/sample.rb', line 31 def initialize(name, path, parent=nil) super(name) [:path]=path @parent = parent end |
Instance Method Details
#add_filename(filename) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/bio/ngs/illumina/sample.rb', line 45 def add_filename(filename) = filename.dup = {:filename=>} #TODO maybe could be usefult to leave this to end used, define what is a filtered/trimmed file. Define a regexp for each category. if filename=~/trimmed|TRIMMED/ [:trimmed] = true [:trimmed_aggregated] = true unless filename=~/_\d+\./ end if filename=~/filtered|FILTERED/ [:filtered] = true [:filtered_aggregated] =true unless filename=~/_\d+\./ end [:left] = true if filename=~/.*_R1_.*/ [:right] = true if filename=~/.*_R2_.*/ [:zipped] = true if filename=~/\.gz/ [:aggregated] = true unless [:trimmed_aggregated] || [:filtered_aggregated] || filename=~/_\d+\./ filename.sub!(/_([ACGT]+)_/,'_') [:index] = $1 filename.sub!(/_L([0-9]+)_?/,'_') [:lane] = $1 #filename_cleaned = filename.sub(/_R.*/,'') readsdata_name = File.basename(filename).sub(/TRIMMED/,'').sub(/trimmed/,'').sub(/filtered/,'').sub(/FILTERED/,'').sub(/_R\d+_\d+_?/,'').sub(/_R\d+_/,'').sub(/\..+$/,'') #TODO is not the best thing to do if filename=~/R._(\d*).fastq(.gz)?/ [:chunks]=$1 end self.add MetaReads.new(SecureRandom.uuid, ) end |
#filenames_paths ⇒ Object
REMOVE # def get(tag=filtered)
@files.get(tag)
end
81 82 83 84 85 |
# File 'lib/bio/ngs/illumina/sample.rb', line 81 def filenames_paths @filenames.keys.map do |filename| filename_path(filename) end.flatten end |
#paired? ⇒ Boolean
41 42 43 |
# File 'lib/bio/ngs/illumina/sample.rb', line 41 def paired? @filenames.key?(:left) && @filenames.key?(:right) end |
#path ⇒ Object
37 38 39 |
# File 'lib/bio/ngs/illumina/sample.rb', line 37 def path File.join @parent.path,"Sample_#{name}" end |
#to_json(*a) ⇒ Object
87 88 89 90 91 92 93 94 |
# File 'lib/bio/ngs/illumina/sample.rb', line 87 def to_json(*a) { "json_class" => self.class.name, "name" => name, "metadata" => , "files" => pool }.to_json(*a) end |