Module: Bio::Ngs::Illumina
- Defined in:
- lib/bio/ngs/illumina/fastq.rb,
lib/bio/ngs/illumina/sample.rb,
lib/bio/ngs/illumina/project.rb,
lib/bio/ngs/illumina/illumina.rb
Defined Under Namespace
Modules: FastqGz
Classes: MetaReads, Project, Projects, Sample
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.build(path = ".") ⇒ Object
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/bio/ngs/illumina/illumina.rb', line 38
def build(path=".")
projects = Projects.new("Illumina", path)
Dir.chdir(path) do
Dir.glob(["**/Project_*","**/Undetermined_indices"]).each do |project_dir|
project = Project.new(project_dir.sub(/.*Project_/,""),project_dir)
projects.add(project)
Dir.chdir(project_dir) do
Dir.glob("Sample*").each do |sample_dir|
sample = Sample.new(sample_dir.sub(/Sample_/,""), sample_dir, project)
project.add(sample)
Dir.chdir(sample_dir) do
Dir.glob(["**/*.fastq", "**/*.fastq.gz"]) do |reads_filename|
sample.add_filename(reads_filename)
end
end
end
end
end
end
projects
end
|
.project_directory?(path = ".") ⇒ Boolean
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/bio/ngs/illumina/illumina.rb', line 21
def project_directory?(path=".")
Dir.chdir(path) do
projects = Dir.glob(["Project_*","Undetermined_indices"])
return false if projects.empty?
into_projects = projects.map do |project|
Dir.chdir(project) do |sample|
Dir.glob("Sample*").size>0
end
end.uniq
if (into_projects.size>1 || (into_projects.first==false))
return false
end
end
true
end
|
Instance Method Details
#filter(file) ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/bio/ngs/illumina/fastq.rb', line 9
def filter(file)
if File.exists? file
filtered_file_basename = File.basename(file)
filtered_dir = File.join(File.dirname,"filtered")
Dir.mkdir(filtered_dir) unless Dir.exists?(filtered_dir)
FastqGz.gets_compressed(filtered_file_basename) do |compress|
FastqGz.gets_filtered(ftest) do |, reader_seq, read_splitter, read_qual|
compress.write( + reader_seq + read_splitter + read_qual)
end
end
else
raise "Bio::Ngs::Illumina.filter : unkown file #{file}"
end
end
|