Esempio n. 1
0
 def __call__(self, cpus=None):
     # Check it is installed #
     self.check_installed()
     # Check version #
     assert "v0.11.9" in sh.fastqc('-version')
     # Number of cores #
     if cpus is None: cpus = min(multiprocessing.cpu_count(), 32)
     # Make a temporary directory #
     self.tmp_dir = new_temp_dir()
     # Run it #
     sh.fastqc(self.source, '-o', self.tmp_dir, '-t', cpus, '--extract')
     # Get location of results #
     components = self.source.prefix.split('.')
     if components[-1] == 'gz':    components.pop()
     if components[-1] == 'fastq': components.pop()
     # Reassemble the components #
     created_name = '.'.join(components) + '_fastqc/'
     # This will be the name of the directory that fastqc created #
     created_dir  = self.tmp_dir + created_name
     # Move results #
     if self.dest.exists: shutil.rmtree(self.dest)
     shutil.move(created_dir, self.dest)
     self.tmp_dir.remove()
     # Return #
     return self.results
Esempio n. 2
0
 def raw(self):
     # Link #
     if os.path.lexists(self.p.raw_fastq): os.remove(self.p.raw_fastq)
     os.symlink(self.path, self.p.raw_fastq)
     # Fast QC #
     sh.fastqc(self.p.raw_fastq, '-o', self.p.raw_dir, '-q')
     if os.path.exists(self.p.raw_dir + 'raw_fastqc.zip'): os.remove(self.p.raw_dir + 'raw_fastqc.zip')
Esempio n. 3
0
 def raw(self):
     # Call extraction #
     shell_output('sffinfo -s %s > %s' % (self.p.raw_sff, self.p.raw_fasta))
     shell_output('sffinfo -q %s > %s' % (self.p.raw_sff, self.p.raw_qual))
     shell_output('sffinfo -m %s > %s' % (self.p.raw_sff, self.p.manifest))
     # Convert #
     sh.fasta_to_fastq(self.p.raw_fasta, self.p.raw_qual, self.p.raw_fastq)
     # Fast QC #
     sh.fastqc(self.p.raw_fastq, '-o', self.p.raw_dir, '-q')
     if os.path.exists(self.p.raw_dir + 'raw_fastqc.zip'): os.remove(self.p.raw_dir + 'raw_fastqc.zip')
Esempio n. 4
0
 def run(self):
     # Sliding window procedure #
     clean(infile=self.parent.p.raw_fastq, outfile=self.parent.p.clean_fastq,
           keeptrim=self.parent.p.trim_fastq, format='fastq',
           minlength=150, threshold=21, windowsize=20)
     # Back to FASTA #
     sh.fastq_to_fasta(self.parent.p.clean_fastq, self.parent.p.clean_fasta, self.parent.p.clean_qual)
     # Fast QC #
     sh.fastqc(self.parent.p.clean_fastq, '-o', self.parent.p.clean_dir, '-q')
     os.remove(self.parent.p.clean_dir + 'clean_fastqc.zip')
Esempio n. 5
0
 def fastqc(self):
     # Call #
     sh.fastqc(self.path, '-q')
     # Paths #
     zip_file = self.prefix_path + '_fastqc.zip'
     report_dir = self.prefix_path + '_fastqc/'
     #images_dir = self.prefix_path + '_fastqc/Images/'
     # Clean up #
     os.remove(zip_file)
     # Return #
     return report_dir
Esempio n. 6
0
 def run(self):
     if self.dest is None:
         sh.fastqc(self.source, '-q')
         os.remove(self.source.prefix_path + '_fastqc.zip')
     if self.dest is not None:
         if self.dest.exists: self.dest.remove()
         self.tmp_dir = new_temp_dir()
         sh.fastqc(self.source, '-q', '-o', self.tmp_dir)
         created_dir = self.tmp_dir + self.source.prefix.split('.')[0] + '_fastqc/'
         shutil.move(created_dir, self.dest)
         self.tmp_dir.remove()
         return self.results
Esempio n. 7
0
 def fastqc(self, directory):
     # Symbolic link #
     tmp_dir = tempfile.mkdtemp() + '/'
     if self.gziped: sym_fwd_path = tmp_dir + 'fwd.fastq.gz'
     else:           sym_fwd_path = tmp_dir + 'fwd.fastq'
     if self.gziped: sym_rev_path = tmp_dir + 'rev.fastq.gz'
     else:           sym_rev_path = tmp_dir + 'rev.fastq'
     os.symlink(self.fwd_path, sym_fwd_path)
     os.symlink(self.rev_path, sym_rev_path)
     # Call #
     sh.fastqc(sym_fwd_path, '-q')
     sh.fastqc(sym_rev_path, '-q')
     # Move #
     shutil.move(tmp_dir + 'fwd_fastqc/', directory + "fwd_fastqc/")
     shutil.move(tmp_dir + 'rev_fastqc/', directory + "rev_fastqc/")
     # Clean up #
     shutil.rmtree(tmp_dir)
Esempio n. 8
0
 def fastqc(self, directory):
     # Symbolic link #
     tmp_dir = tempfile.mkdtemp() + '/'
     if self.gziped: sym_fwd_path = tmp_dir + 'fwd.fastq.gz'
     else:           sym_fwd_path = tmp_dir + 'fwd.fastq'
     if self.gziped: sym_rev_path = tmp_dir + 'rev.fastq.gz'
     else:           sym_rev_path = tmp_dir + 'rev.fastq'
     os.symlink(self.fwd_path, sym_fwd_path)
     os.symlink(self.rev_path, sym_rev_path)
     # Call #
     sh.fastqc(sym_fwd_path, '-q')
     sh.fastqc(sym_rev_path, '-q')
     # Move #
     shutil.rmtree(directory + "fwd_fastqc/", ignore_errors=True)
     shutil.rmtree(directory + "rev_fastqc/", ignore_errors=True)
     shutil.move(tmp_dir + 'fwd_fastqc/', directory + "fwd_fastqc/")
     shutil.move(tmp_dir + 'rev_fastqc/', directory + "rev_fastqc/")
     # Clean up #
     shutil.rmtree(tmp_dir)
Esempio n. 9
0
 def assembly_fastqc(self):
     sh.fastqc(self.assembled.path, '-q')
     os.remove(os.path.splitext(self.assembled.path)[0] + '_fastqc.zip')
Esempio n. 10
0
 def barcode_fastqc(self):
     sh.fastqc(self.fwd_path, '-q')
     os.remove(os.path.splitext(self.fwd_path)[0] + '_fastqc.zip')
     sh.fastqc(self.rev_path, '-q')
     os.remove(os.path.splitext(self.rev_path)[0] + '_fastqc.zip')
Esempio n. 11
0
 def check(self):
     assert sh.fastqc('--v', )
Esempio n. 12
0
 def assembly_fastqc(self):
     sh.fastqc(self.assembled.path, '-q')
     os.remove(os.path.splitext(self.assembled.path)[0] + '_fastqc.zip')
Esempio n. 13
0
 def barcode_fastqc(self):
     sh.fastqc(self.fwd_path, '-q')
     os.remove(os.path.splitext(self.fwd_path)[0] + '_fastqc.zip')
     sh.fastqc(self.rev_path, '-q')
     os.remove(os.path.splitext(self.rev_path)[0] + '_fastqc.zip')