def test_build_sampledir(): demux_root = 'tests/fixtures/demux' run_folder = '150410_D00134_0189_BHF3GKADXX' true_sample_id = 'ADM992A9' false_sample_id = 'ADM992A9fake' # test with existing sample run dir sample_rundir = build_sampledir(demux_root, run_folder, true_sample_id) the_rundir = ("tests/fixtures/demux/150410_D00134_0189_BHF3GKADXX/" "Unaligned2/Project_600597/Sample_ADM992A9_XTA02/") assert sample_rundir == the_rundir # test with non-existing sample run dir with pytest.raises(AttributeError): build_sampledir(demux_root, run_folder, false_sample_id)
def get_fastq_files(self, flowcell_id, sample_id): """Retrive FASTQ files for a sample run directory.""" demux_root = self.config['general']['demux_root'] rundir_path = self.get_rundir(flowcell_id) run_folder = path(rundir_path).basename() logger.debug('create related FASTQ-file records') sample_rundir = build_sampledir(demux_root, run_folder, sample_id) fastq_files = sample_fastqfiles(sample_rundir, basename=True) return fastq_files
def post_symlink_spof(demux_root, flowcell_id, sample_id, reason='analysis'): """Assemble/symlink files for a sample flowcell directory. Args: demux_root (str): root path to demux folder sample_id (str): globally unique sample id flowcell_id (str): flowcell id """ logger.debug('gather information from LIMS') sample_res = glue.get('lims', 'samples', sample_id) analysis_type = sample_res.json['analysis_type'] case_id = sample_res.json['family_id'] cust_id = sample_res.json['customer'] logger.debug('gather information from status db') spof_res = glue.get('moneypenny', 'spofs', flowcell_id, sample_id) demux_folder = spof_res.json['flowcell']['demux_folder'] demuxed_at = dateify(spof_res.json['flowcell']['demuxed_at']).date() spof_dir = build_sampledir(demux_root, demux_folder, sample_id) fastq_paths = [spof_dir.joinpath(fq_file['file_name']) for fq_file in spof_res.json['fastq_files']] logger.debug("symlink FASTQ files for %s/%s", sample_id, flowcell_id) payload = {'cust_id': cust_id, 'case_id': case_id, 'analysis_type': analysis_type, 'fastq_paths': fastq_paths, 'demuxed_at': demuxed_at.strftime('%y%m%d')} symlink_res = glue.post('assemble', 'spofs', 'prepare', flowcell_id, sample_id, data=payload) for fastq_path, symlink_path in symlink_res.json['symlinks']: fastq_file = path(fastq_path).basename() data = {'fastq_file': fastq_file, 'symlink': symlink_path, 'flowcell_id': flowcell_id, 'reason': reason} glue.post('moneypenny', 'symlinks', data=data) return symlink_res.json