def __init__(self, bam, sample_info_file, sample_id, output_sh, genome, walltime, submit=False): """ Parameters ---------- Returns ------- Raises ------ """ self.sample_info_file = sample_info_file if self.sample_info_file is not None: sample_info = pd.read_table(self.sample_info_file, header=None) self.bams = sample_info[0] self.sample_ids = sample_info[1] self.sh_files = ['{}.miso.sh'.format(bam) for bam in self.bams] self.multiple_samples = True else: self.sample_ids = [sample_id] self.bams = [bam] self.sh_files = [output_sh] self.multiple_samples = False self.genome = genome self.walltime = walltime self.submit = submit all_samples_commands = [] for bam, sample_id, sh_file in zip(self.bams, self.sample_ids, self.sh_files): self._write_single_sample(bam, sample_id, sh_file) sh_command = 'bash {}'.format(sh_file) if self.submit and not self.multiple_samples: commands = [sh_command] sub = Submitter(commands, job_name='miso', sh_filename='{}.qsub.sh'.format(sh_file), ppn=16, walltime=self.walltime) sub.job(submit=self.submit) if self.multiple_samples: all_samples_commands.append(sh_command) if self.multiple_samples: sub = Submitter(all_samples_commands, job_name='miso', sh_filename='miso.qsub.sh', array=True, ppn=16, walltime=self.walltime) sub.job(submit=self.submit)
def __init__(self, genomeDir, genomeFastaFiles, sjdb, sjdbOverhang, job_name, out_sh=None, submit=True): """Any CamelCase here is directly copied from the STAR inputs for complete compatibility """ # Make the directory if it's not there already try: os.mkdir(genomeDir) except OSError: pass commands = [] commands.append('STAR --runMode genomeGenerate --genomeDir {0} ' '--genomeFastaFiles {1} --runThreadN 16 {2} ' '--sjdbOverhang {3}'.format( genomeDir, genomeFastaFiles, sjdb, sjdbOverhang)) sub = Submitter(queue_type='PBS', sh_filename=out_sh, commands=commands, job_name=job_name, nodes=1, ppn=16, queue='home', walltime='4:00:00') sub.job(submit=submit)
def test_pbs(self): """Test PBS queue (TSCC) """ job_name = 'test_qtools_submitter_pbs' submit_sh = '{}/{}.sh'.format(self.out_dir, job_name) sub = Submitter(queue_type='PBS', sh_filename=submit_sh, commands=self.commands, job_name=job_name, nodes=1, ppn=1, queue='home-yeo', walltime='0:01:00') job_id = sub.job(submit=False) true_result_string = '''#!/bin/bash #PBS -N test_qtools_submitter_pbs #PBS -o {0}/test_qtools_submitter_pbs.sh.out #PBS -e {0}/test_qtools_submitter_pbs.sh.err #PBS -V #PBS -l walltime=0:01:00 #PBS -l nodes=1:ppn=1 #PBS -A yeo-group #PBS -q home-yeo # Go to the directory from which the script was called cd $PBS_O_WORKDIR date echo testing '''.format(self.out_dir) true_result = true_result_string.split('\n') # with open(submit_sh) as f: # for x in f.readlines(): # print x, for true, test in zip(true_result, open(submit_sh)): self.assertEqual(true.strip().split(), test.strip().split()) # Make sure the job ID is a single (potentially multi-digit) integer # But only do this if we're on TSCC or oolite if ON_SERVER: self.assertRegexpMatches(job_id, '^\d+$') subprocess.Popen(["qdel", job_id], stdout=PIPE)
def test_pbs(self): """Test PBS queue (TSCC) """ job_name = 'test_qtools_submitter_pbs' submit_sh = '{}/{}.sh'.format(self.out_dir, job_name) sub = Submitter(queue_type='PBS', sh_filename=submit_sh, commands=self.commands, job_name=job_name, nodes=1, ppn=1, queue='home-yeo', walltime='0:01:00' ) job_id = sub.job(submit=False) true_result_string = '''#!/bin/bash #PBS -N test_qtools_submitter_pbs #PBS -o {0}/test_qtools_submitter_pbs.sh.out #PBS -e {0}/test_qtools_submitter_pbs.sh.err #PBS -V #PBS -l walltime=0:01:00 #PBS -l nodes=1:ppn=1 #PBS -A yeo-group #PBS -q home-yeo # Go to the directory from which the script was called cd $PBS_O_WORKDIR date echo testing '''.format(self.out_dir) true_result = true_result_string.split('\n') # with open(submit_sh) as f: # for x in f.readlines(): # print x, for true, test in zip(true_result, open(submit_sh)): self.assertEqual(true.strip().split(), test.strip().split()) # Make sure the job ID is a single (potentially multi-digit) integer # But only do this if we're on TSCC or oolite if ON_SERVER: self.assertRegexpMatches(job_id, '^\d+$') subprocess.Popen(["qdel", job_id], stdout=PIPE)
def test_sge(self): """Test SGE queue (oolite) """ job_name = 'test_qtools_submitter_sge' submit_sh = '{}/{}.sh'.format(self.out_dir, job_name) sub = Submitter(queue_type='SGE', sh_filename=submit_sh, commands=self.commands, job_name=job_name, nodes=1, ppn=1, queue='home-yeo', walltime='0:01:00') job_id = sub.job(submit=False) true_result_string = '''#!/bin/bash #$ -N test_qtools_submitter_sge #$ -o {0}/test_qtools_submitter_sge.sh.out #$ -e {0}/test_qtools_submitter_sge.sh.err #$ -V #$ -S /bin/bash #$ -cwd #$ -l bigmem #$ -l h_vmem=16G date echo testing '''.format(self.out_dir) true_result = true_result_string.split('\n') # with open(submit_sh) as f: # for x in f.readlines(): # print x, for true, test in zip(true_result, open(submit_sh)): self.assertEqual(true.strip().split(), test.strip().split()) # Make sure the job ID is a single (potentially multi-digit) integer # But only do this if we're on TSCC or oolite if ON_SERVER: self.assertRegexpMatches(job_id, '^\d+$') subprocess.Popen(["qdel", job_id], stdout=PIPE)
def test_sge(self): """Test SGE queue (oolite) """ job_name = 'test_qtools_submitter_sge' submit_sh = '{}/{}.sh'.format(self.out_dir, job_name) sub = Submitter(queue_type='SGE', sh_filename=submit_sh, commands=self.commands, job_name=job_name, nodes=1, ppn=1, queue='home-yeo', walltime='0:01:00' ) job_id = sub.job(submit=False) true_result_string = '''#!/bin/bash #$ -N test_qtools_submitter_sge #$ -o {0}/test_qtools_submitter_sge.sh.out #$ -e {0}/test_qtools_submitter_sge.sh.err #$ -V #$ -S /bin/bash #$ -cwd #$ -l bigmem #$ -l h_vmem=16G date echo testing '''.format(self.out_dir) true_result = true_result_string.split('\n') # with open(submit_sh) as f: # for x in f.readlines(): # print x, for true, test in zip(true_result, open(submit_sh)): self.assertEqual(true.strip().split(), test.strip().split()) # Make sure the job ID is a single (potentially multi-digit) integer # But only do this if we're on TSCC or oolite if ON_SERVER: self.assertRegexpMatches(job_id, '^\d+$') subprocess.Popen(["qdel", job_id], stdout=PIPE)
def __init__(self, bam, sample_info_file, sample_id, output_sh, genome, walltime, nodes=1, ppn=16, submit=False, read_length=None): """ Parameters ---------- Returns ------- Raises ------ """ self.sample_info_file = sample_info_file if self.sample_info_file is not None: sample_info = pd.read_table(self.sample_info_file, header=None) self.bams = sample_info[0] self.sample_ids = sample_info[1] self.sh_files = ['{}.miso.sh'.format(bam) for bam in self.bams] self.multiple_samples = True else: self.sample_ids = [sample_id] self.bams = [bam] self.sh_files = [output_sh] self.multiple_samples = False self.genome = genome self.walltime = walltime self.submit = submit self.nodes = nodes self.ppn = ppn self.read_length = self.read_length all_samples_commands = [] for bam, sample_id, sh_file in zip(self.bams, self.sample_ids, self.sh_files): self._write_single_sample(bam, sample_id, sh_file) sh_command = 'bash {}'.format(sh_file) if self.submit and not self.multiple_samples: commands = [sh_command] sub = Submitter(commands, job_name='miso', sh_filename='{}.qsub.sh'.format(sh_file), ppn=self.ppn, nodes=self.nodes, walltime=self.walltime) sub.job(submit=self.submit) if self.multiple_samples: all_samples_commands.append(sh_command) if self.multiple_samples: sub = Submitter(all_samples_commands, job_name='miso', sh_filename='miso.qsub.sh', array=True, ppn=self.ppn, nodes=self.nodes, walltime=self.walltime) sub.job(submit=self.submit)
print species except: print "usage: submit_parse_oldsplice.py <species>" assert (species != None) and (len(species) > 0) for filename in files: filenames.append(filename) sample = filename.replace(".splices", "").replace(".flip", "_flip") samples.append(sample) from gscripts.qtools import Submitter sub = Submitter() cmd = "parse_oldsplice.py --species %s" %species for filename, sample in zip(filenames, samples): cmd += " --sample %s %s " %(filename, sample) #print cmd cmd = [cmd] sub.job(command_list=cmd, array=False, sh_file="parse.sh", job_name="parse", submit=True, queue="home", ppn=1)