Ejemplo n.º 1
0
def test_extract_flowcell():
    run_dir = 'tests/fixtures/demux/150410_D00134_0189_BHF3GKADXX'
    flowcell_id = extract_flowcell(run_dir)
    assert flowcell_id == 'HF3GKADXX'

    # test with trailing slash
    run_dir = 'tests/fixtures/demux/150410_D00134_0189_BHF3GKADXX/'
    flowcell_id = extract_flowcell(run_dir)
    assert flowcell_id == 'HF3GKADXX'
Ejemplo n.º 2
0
def add_flowcell(flowcell_dir, samples=None):
    """Create a new instance of a Spof to the database."""
    logger.debug('extracting info from run dir')
    flowcell_id = extract_flowcell(flowcell_dir)
    demux_date = date_from_rundir(flowcell_dir)
    run_folder = path(flowcell_dir).realpath().basename()

    logger.debug('check of the flowcell already exists')
    flowcell_obj = Flowcell.query.filter_by(flowcell_id=flowcell_id).first()
    if flowcell_obj is None:
        if samples is None:
            sample_rundirs = get_sample_rundirs(flowcell_dir)
            sample_ids = (sample_from_rundir(sample_dir)
                          for sample_dir in sample_rundirs)
            samples = [Sample.query.filter_by(lims_id=sample_id).one()
                       for sample_id in sample_ids]

        logger.debug('creating new Flowcell record')
        flowcell_obj = Flowcell(flowcell_id=flowcell_id,
                                demux_folder=run_folder,
                                demuxed_at=demux_date,
                                samples=samples)

        logger.debug('committing to database')
    return flowcell_obj
Ejemplo n.º 3
0
    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)