def setUp(self): self.rootdir = tempfile.mkdtemp(prefix="test_illumina_run_") # Create a fcdir self.exp_fcid = td.generate_fc_barcode() self.exp_fcdir = os.path.join(self.rootdir,td.generate_run_id(fc_barcode=self.exp_fcid)) os.mkdir(self.exp_fcdir) # Create multiple sequence read directories self.exp_seqdir = [os.path.join(self.exp_fcdir,"Unaligned"), os.path.join(self.exp_fcdir,"Unaligned_L6"), os.path.join(self.exp_fcdir,"Unaligned_L8")] for d in self.exp_seqdir: os.mkdir(d) # Create directories for undetermined indices reads self.exp_unmatched_directory = [os.path.join(d,"Undetermined_indices") for d in self.exp_seqdir[:-1]] for d in self.exp_unmatched_directory: os.mkdir(d) # Create basecall stats directories self.exp_basecall_stats = [os.path.join(d,"Basecall_Stats_{}".format(self.exp_fcid)) for d in self.exp_seqdir[1:]] for d in self.exp_basecall_stats: os.mkdir(d) self.run = IlluminaRun(self.exp_fcdir)
def test_get_samplesheet(self): """Locate the samplesheet in a folder """ # Work in a separate subdirectory subdir = os.path.join(self.rootdir,"test_get_samplesheet") os.mkdir(subdir) # Create a few random files and folders and assert that they are not returned suffixes = [".csv","",""] for n in range(3): os.mkdir(os.path.join(subdir,''.join(random.choice(string.ascii_uppercase) for x in range(5)))) fh, _ = tempfile.mkstemp(dir=subdir, suffix=suffixes[n]) os.close(fh) self.assertIsNone(IlluminaRun.get_samplesheet(subdir), "Getting non-existing samplesheet did not return None") # Create a SampleSheet.csv and a [FCID].csv file and assert that they are # returned with a preference for the [FCID].csv file fcid = td.generate_fc_barcode() fcdir = os.path.join(subdir,td.generate_run_id(fc_barcode=fcid)) os.mkdir(fcdir) ss = [os.path.join(fcdir,"SampleSheet.csv"), os.path.join(fcdir,"{}.csv".format(fcid))] for s in ss: utils.touch_file(s) self.assertEqual(s,IlluminaRun.get_samplesheet(fcdir), "Did not get existing {}".format(os.path.basename(s))) shutil.rmtree(subdir)
def test_get_samplesheet(self): """Test that the _get_samplesheet method behaves as expected """ # Create a few random files and folders and assert that they are not returned suffixes = [".csv","",""] for n in range(3): os.mkdir(os.path.join(self.rootdir,''.join(random.choice(string.ascii_uppercase) for x in range(5)))) fh, _ = tempfile.mkstemp(dir=self.rootdir, suffix=suffixes[n]) os.close(fh) self.assertIsNone(sq.get_samplesheet(self.rootdir), "Getting non-existing samplesheet did not return None") # Create a SampleSheet.csv and a [FCID].csv file and assert that they are # returned with a preference for the [FCID].csv file fcid = td.generate_fc_barcode() fcdir = os.path.join(self.rootdir,td.generate_run_id(fc_barcode=fcid)) os.mkdir(fcdir) ss = [os.path.join(fcdir,"SampleSheet.csv"), os.path.join(fcdir,"{}.csv".format(fcid))] for s in ss: utils.touch_file(s) self.assertEqual(s,sq.get_samplesheet(fcdir), "Did not get existing {}".format(os.path.basename(s)))
def setUp(self): self.rootdir = tempfile.mkdtemp(prefix="test_illumina_run_") # Create a fcdir self.exp_fcid = td.generate_fc_barcode() self.exp_fcdir = os.path.join( self.rootdir, td.generate_run_id(fc_barcode=self.exp_fcid)) os.mkdir(self.exp_fcdir) # Create multiple sequence read directories self.exp_seqdir = [ os.path.join(self.exp_fcdir, "Unaligned"), os.path.join(self.exp_fcdir, "Unaligned_L6"), os.path.join(self.exp_fcdir, "Unaligned_L8") ] for d in self.exp_seqdir: os.mkdir(d) # Create directories for undetermined indices reads self.exp_unmatched_directory = [ os.path.join(d, "Undetermined_indices") for d in self.exp_seqdir[:-1] ] for d in self.exp_unmatched_directory: os.mkdir(d) # Create basecall stats directories self.exp_basecall_stats = [ os.path.join(d, "Basecall_Stats_{}".format(self.exp_fcid)) for d in self.exp_seqdir[1:] ] for d in self.exp_basecall_stats: os.mkdir(d) self.run = IlluminaRun(self.exp_fcdir)
def test_get_flowcelldirs(self): """Test that the _get_flowcelldirs method behaves as expected """ # Create a few random files and folders and assert that they are not returned for n in range(3): os.mkdir(os.path.join(self.rootdir,''.join(random.choice(string.ascii_uppercase) for x in range(5)))) fh, _ = tempfile.mkstemp(dir=self.rootdir) os.close(fh) self.assertListEqual([], sq.get_flowcelldirs(self.rootdir), "Listing available flowcells did not return an empty list") # Create a few flowcell directories and make sure that they are returned fcdirs = [] for n in range(3): fcdirs.append(os.path.join(self.rootdir,td.generate_run_id())) os.mkdir(fcdirs[-1]) fcdirs = sorted(fcdirs) self.assertListEqual(fcdirs,sorted(sq.get_flowcelldirs(self.rootdir)), "Listing available flowcells did not return the 3 expected folders") # Test that filtering based on flowcell name works self.assertListEqual([fcdirs[-1]],sq.get_flowcelldirs(self.rootdir,os.path.basename(fcdirs[-1])), "Filtering based on flowcell name did not returned the expected output") # Test that filtering based on partial flowcell name works self.assertListEqual([fcdirs[-1]],sq.get_flowcelldirs(self.rootdir,os.path.basename(fcdirs[-1][10:])), "Filtering based on partial flowcell name did not returned the expected output")