def test_split_fastq(): parts = split_fastq(FASTQ_PATH) assert parts['sample'] == 'ADM992A10' assert parts['index'] == 'GAGCTGAA' assert parts['lane'] == 2 assert parts['read'] == 1 assert parts['segment'] == 1
def add_symlink(self, fastq_file, symlink, reason='analysis'): parts = split_fastq(fastq_file) # fetch relevant unaligned record run_dir = get_run_dir(fastq_file) flowcell_id = extract_flowcell(run_dir) unaligned_obj = self._get_unaligned(parts['sample'], flowcell_id) fastq_obj = (self.db.query(FastqFile) .filter_by(lane=parts['lane'], read=parts['read'], segment=parts['segment'], unaligned=unaligned_obj) .one()) logger.debug('saving symlink to database') symlink_obj = Symlink(path=symlink, reason=reason, original=fastq_obj) self.add_commit(symlink_obj)
def post(self): fastq_file = request.form['fastq_file'] symlink = request.form['symlink'] flowcell_id = request.form['flowcell_id'] reason = request.form.get('reason', 'analysis') parts = split_fastq(fastq_file) # fetch relevant spof record spof_obj = utils.get_spof(flowcell_id, parts['sample']) filters = dict(lane=parts['lane'], read=parts['read'], segment=parts['segment'], spof=spof_obj) fastq_obj = FastqFile.query.filter_by(**filters).one() logger.debug('saving symlink to database') symlink_obj = Symlink(path=symlink, reason=reason, original=fastq_obj) utils.commit(symlink_obj) return symlink_obj.to_json()
def add_fastq_file(fastq_file, sample_obj, spof_obj): """Add FASTQ-file to the database.""" parts = split_fastq(fastq_file) common_params = dict(lane=parts['lane'], barcode=parts['index'], segment=parts['segment'], spof=spof_obj, sample=sample_obj) fastq_obj, was_created = get_or_create(FastqFile, file_name=fastq_file, read=parts['read'], **common_params) # logger.debug('adding read partner') # other_read = 2 if parts['read'] == 1 else 1 # fastq_partner = FastqFile.query.filter_by(read=other_read, # **common_params).first() # if fastq_partner: # fastq_obj.sibling = fastq_partner # fastq_partner.sibling = fastq_obj return fastq_obj
def add_fastq_file(self, fastq_file, sample_obj, unaligned_obj): parts = split_fastq(fastq_file) common_params = dict(lane=parts['lane'], barcode=parts['index'], segment=parts['segment'], unaligned=unaligned_obj, sample=sample_obj) (fastq_obj, was_created) = self.db.get_or_create(FastqFile, file_name=fastq_file, read=parts['read'], **common_params) logger.debug('looking up FASTQ read partner') other_read = 2 if parts['read'] == 1 else 1 fastq_partner = (self.db.query(FastqFile) .filter_by(read=other_read, **common_params) .first()) fastq_obj.sibling = fastq_partner self.db.save() if fastq_partner: fastq_partner.sibling = fastq_obj self.db.save() return fastq_obj
def build_mip_fastq_path(fastq_base, fastq_path, flowcell_id, date): parts = split_fastq(fastq_path) mip_fastq = build_mip_fastq(date=date, flowcell=flowcell_id, **parts) mip_fastq_path = path(fastq_base).normpath().joinpath(mip_fastq) return mip_fastq_path