Module: Bio::Ngs::FS
- Defined in:
- lib/bio/ngs/fs.rb
Class Method Summary collapse
-
.cat(files, merged) ⇒ Object
(also: merge)
Write a file ‘merged’ which is the concatenation of multipes fastq.gz ‘files’ files is an array of filenames.
- .files(everything, suffix = nil) ⇒ Object
Class Method Details
.cat(files, merged) ⇒ Object Also known as: merge
Write a file ‘merged’ which is the concatenation of multipes fastq.gz ‘files’ files is an array of filenames
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/bio/ngs/fs.rb', line 10 def cat(files, merged) if files.is_a? Array File.open(merged,'wb') do |fmerge| files.each do |fname| File.open(fname,'rb:binary') do |file| while line = file.gets fmerge << line end end #read end #each end #write end #if end |
.files(everything, suffix = nil) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/bio/ngs/fs.rb', line 26 def files(everything, suffix=nil) if everything.is_a? String if File.file? everything [File.(everything)] elsif File.directory? everything files(Dir.glob(File.join(everything, suffix.nil? ? "*" : "*"+suffix)).select{|item| File.file? item}).flatten elsif everything=~/\*/ files(Dir.glob(everything)).flatten elsif everything=~/[ ,:;]/ files(everything.split(/[ ,:;]/)) end elsif everything.is_a? Array everything.map do |item| files(item) end.flatten end end |