Exemple #1
0
    def get(self):
        limsg = lims.Lims(BASEURI, USERNAME, PASSWORD)
        queues = {}
        queues['TruSeqRNAprep'] = Queue(limsg, id='311')
        queues['TruSeqSmallRNA'] = Queue(limsg, id='410')
        queues['TruSeqDNAPCR_free'] = Queue(limsg, id='407')
        queues['ThruPlex'] = Queue(limsg, id='451')
        queues['Genotyping'] = Queue(limsg, id='901')
        queues['RadSeq'] = Queue(limsg, id='1201')
        queues['SMARTerPicoRNA'] = Queue(limsg, id='1551')
        queues['ChromiumGenomev2'] = Queue(limsg, id='1801')

        methods = queues.keys()
        pools = {}

        for method in methods:
            pools[method] = {}
            for artifact in queues[method].artifacts:
                name = artifact.name
                project = artifact.name.split('_')[0]
                if project in pools[method]:
                    pools[method][project]['samples'].append(name)
                else:
                    total_num_samples = limsg.get_sample_number(
                        projectlimsid=project)
                    proj = Project(limsg, id=project)
                    try:
                        date_queued = proj.udf['Queued'].strftime("%Y-%m-%d")
                    except KeyError:
                        # Queued should really be on a project at this point, but mistakes happen
                        date_queued = None
                    projName = proj.name
                    pools[method][project] = {
                        'total_num_samples': total_num_samples,
                        'queued_date': date_queued,
                        'pname': projName,
                        'samples': [name]
                    }

        self.set_header("Content-type", "application/json")
        self.write(json.dumps(pools))
Exemple #2
0
    def get(self):
        limsl = lims.Lims(BASEURI, USERNAME, PASSWORD)
        #qPCR queues
        queues = {}
        queues['MiSeq'] = Queue(limsl, id='1002')
        queues['NovaSeq'] = Queue(limsl, id='1666')
        queues['LibraryValidation'] = Queue(limsl, id='41')

        methods = queues.keys()
        pools = {}

        for method in methods:
            pools[method] = {}
            if queues[method].artifacts:
                tree = ET.fromstring(queues[method].xml())
                if tree.find('next-page') is not None:
                    flag = True
                    next_page_uri = tree.find('next-page').attrib['uri']
                    while flag:
                        next_page = ET.fromstring(
                            Queue(limsl, uri=next_page_uri).xml())
                        for elem in next_page.findall('artifacts'):
                            tree.insert(0, elem)
                        if next_page.find('next-page') is not None:
                            next_page_uri = next_page.find(
                                'next-page').attrib['uri']
                        else:
                            flag = False
                for artifact in tree.iter('artifact'):
                    queue_time = artifact.find('queue-time').text
                    container = Container(limsl,
                                          uri=artifact.find('location').find(
                                              'container').attrib['uri']).name
                    art = Artifact(limsl, uri=artifact.attrib['uri'])
                    value = artifact.find('location').find('value').text
                    library_type = ''
                    runmode = ''
                    if not 'lambda DNA' in art.name:
                        library_type = art.samples[0].project.udf[
                            "Library construction method"]
                        try:
                            runmode = art.samples[0].project.udf[
                                'Sequencing platform']
                        except KeyError:
                            runmode = 'NA'
                    if container in pools[method]:
                        pools[method][container]['samples'].append({
                            'name':
                            art.name,
                            'well':
                            value,
                            'queue_time':
                            queue_time
                        })
                        if library_type and library_type not in pools[method][
                                container]['library_types']:
                            pools[method][container]['library_types'].append(
                                library_type)
                        if runmode and runmode not in pools[method][container][
                                'runmodes']:
                            pools[method][container]['runmodes'].append(
                                runmode)
                    else:
                        pools[method][container] = {
                            'samples': [{
                                'name': art.name,
                                'well': value,
                                'queue_time': queue_time
                            }],
                            'library_types': [library_type],
                            'runmodes': [runmode]
                        }

        self.set_header("Content-type", "application/json")
        self.write(json.dumps(pools))
Exemple #3
0
    def get(self):
        limsl = lims.Lims(BASEURI, USERNAME, PASSWORD)
        #qPCR queues
        queues = {}
        queues['MiSeq'] = Queue(limsl, id='1002')
        queues['NovaSeq'] = Queue(limsl, id='1666')
        queues['LibraryValidation'] = Queue(limsl, id='41')

        methods = queues.keys()
        pools = {}
        qpcr_control_names = [
            'AM7852', 'E.Coli genDNA', 'Endogenous Positive Control',
            'Exogenous Positive Control', 'Human Brain Reference RNA',
            'lambda DNA', 'mQ Negative Control', 'NA10860', 'NA11992',
            'NA11993', 'NA12878', 'NA12891', 'NA12892',
            'No Amplification Control', 'No Reverse Transcriptase Control',
            'No Template Control', 'PhiX v3', 'Universal Human Reference RNA',
            'lambda DNA (qPCR)'
        ]
        for method in methods:
            pools[method] = {}
            if queues[method].artifacts:
                tree = ET.fromstring(queues[method].xml())
                if tree.find('next-page') is not None:
                    flag = True
                    next_page_uri = tree.find('next-page').attrib['uri']
                    while flag:
                        next_page = ET.fromstring(
                            Queue(limsl, uri=next_page_uri).xml())
                        for elem in next_page.findall('artifacts'):
                            tree.insert(0, elem)
                        if next_page.find('next-page') is not None:
                            next_page_uri = next_page.find(
                                'next-page').attrib['uri']
                        else:
                            flag = False
                for artifact in tree.iter('artifact'):
                    queue_time = artifact.find('queue-time').text
                    container = Container(limsl,
                                          uri=artifact.find('location').find(
                                              'container').attrib['uri']).name
                    art = Artifact(limsl, uri=artifact.attrib['uri'])
                    value = artifact.find('location').find('value').text
                    library_type = ''
                    runmode = ''

                    #skip if the Artifact is a control
                    if art.name in qpcr_control_names:
                        continue

                    library_type = art.samples[0].project.udf.get(
                        "Library construction method", 'NA')
                    try:
                        runmode = art.samples[0].project.udf[
                            'Sequencing platform']
                    except KeyError:
                        runmode = 'NA'
                    if container in pools[method]:
                        pools[method][container]['samples'].append({
                            'name':
                            art.name,
                            'well':
                            value,
                            'queue_time':
                            queue_time
                        })
                        if library_type and library_type not in pools[method][
                                container]['library_types']:
                            pools[method][container]['library_types'].append(
                                library_type)
                        if runmode and runmode not in pools[method][container][
                                'runmodes']:
                            pools[method][container]['runmodes'].append(
                                runmode)
                    else:
                        pools[method][container] = {
                            'samples': [{
                                'name': art.name,
                                'well': value,
                                'queue_time': queue_time
                            }],
                            'library_types': [library_type],
                            'runmodes': [runmode]
                        }

        self.set_header("Content-type", "application/json")
        self.write(json.dumps(pools))
Exemple #4
0
    def get(self):
        limsl = lims.Lims(BASEURI, USERNAME, PASSWORD)
        #sequencing queues are currently taken as the following
        #Miseq- Step 7: Denature, Dilute and load sample
        #Novaseq Step 11: Load to flow cell
        queues = {}
        queues['MiSeq'] = Queue(limsl, id='55')
        queues['NovaSeq'] = Queue(limsl, id='1662')

        methods = queues.keys()
        pools = {}

        for method in methods:
            pools[method] = {}
            if queues[method].artifacts:
                tree = ET.fromstring(queues[method].xml())
                for artifact in tree.iter('artifact'):
                    queue_time = artifact.find('queue-time').text
                    container = Container(limsl,
                                          uri=artifact.find('location').find(
                                              'container').attrib['uri']).name
                    attr_name = Artifact(limsl,
                                         uri=artifact.attrib['uri']).name
                    value = artifact.find('location').find('value').text
                    proj_and_samples = {}
                    conc_qpcr = ''
                    is_rerun = False
                    art = Artifact(limsl, uri=artifact.attrib['uri'])
                    if method is 'MiSeq':
                        #FinishedLibrary
                        if 'Concentration' in dict(art.udf.items()).keys():
                            conc_qpcr = art.udf['Concentration']
                        #InhouseLibrary
                        elif 'Pool Conc. (nM)' in dict(art.udf.items()).keys():
                            conc_qpcr = str(art.udf['Pool Conc. (nM)'])
                        else:
                            pass
                        is_rerun = art.udf["Rerun"]
                    elif method is 'NovaSeq':
                        if 'Concentration' in dict(art.udf.items()).keys():
                            conc_qpcr = art.udf["Concentration"]
                            if 'Rerun' in dict(art.udf.items()).keys():
                                is_rerun = art.udf["Rerun"]
                        else:
                            new_art = art.parent_process.input_output_maps[0][
                                0]
                            # The loop iterates 4 times as the values were found within the first 4 preceding
                            # parent processes(through trial and error). If the values are not found within 4 iterations, they can be looked up
                            # manually in LIMS. The loop is structured so as its not very clear in the genologics API which of the parent processes
                            # will contain the values in post process and 4 seemed to get everything for the data at hand.
                            i = 0
                            while i < 4:
                                if 'Concentration' in dict(
                                        new_art['post-process-uri'].udf.items(
                                        )).keys():
                                    conc_qpcr = new_art[
                                        'post-process-uri'].udf[
                                            "Concentration"]
                                    if 'Rerun' in dict(
                                            new_art['post-process-uri'].udf.
                                            items()).keys():
                                        is_rerun = new_art[
                                            'post-process-uri'].udf["Rerun"]
                                    break
                                else:
                                    new_art = new_art[
                                        'parent-process'].input_output_maps[0][
                                            0]
                                    i = i + 1

                    for sample in art.samples:
                        project = sample.project.id
                        if project in pools[method]:
                            if container in pools[method][project]['plates']:
                                pools[method][project]['plates'][container][
                                    'samples'].append(sample.name)
                            else:
                                pools[method][project]['plates'][container] = {
                                    'samples': [sample.name],
                                    'well': value,
                                    'queue_time': queue_time,
                                    'conc_pool_qpcr': conc_qpcr,
                                    'is_rerun': is_rerun
                                }
                        else:
                            setup = sample.project.udf['Sequencing setup']
                            lanes = sample.project.udf[
                                'Sequence units ordered (lanes)']
                            librarytype = sample.project.udf[
                                'Library construction method']
                            runmode = sample.project.udf['Sequencing platform']
                            final_loading_conc = 'TBD'
                            if method is 'NovaSeq':
                                try:
                                    final_loading_conc = Artifact(
                                        limsl, uri=artifact.attrib['uri']
                                    ).udf['Final Loading Concentration (pM)']
                                except KeyError:
                                    pass
                            pools[method][project] = {
                                'name': sample.project.name,
                                'setup': setup,
                                'lanes': lanes,
                                'runmode': runmode,
                                'final_loading_conc': final_loading_conc,
                                'librarytype': librarytype,
                                'plates': {
                                    container: {
                                        'samples': [sample.name],
                                        'well': value,
                                        'queue_time': queue_time,
                                        'conc_pool_qpcr': conc_qpcr,
                                        'is_rerun': is_rerun
                                    }
                                }
                            }
        self.set_header("Content-type", "application/json")
        self.write(json.dumps(pools))
from genologics.lims import Lims
from genologics.entities import Workflow, Queue, Stage

import config

# Setup lims connection
baseuri = 'https://usf-lims.umcutrecht.nl'
username = '******'
password = '******'
lims = Lims(baseuri, username, password)

old_queue = Queue(
    lims, id=''
)  # Example: Dx Sample registratie zuivering v1.0 = 1142 (same as step id)
old_stage = Stage(
    lims, uri=''
)  # Example: Dx Sample registratie zuivering v1.0 = https://usf-lims.umcutrecht.nl/api/v2/configuration/workflows/751/stages/2119
new_workflow = Workflow(lims, id='')  # Example: Dx Exoom KAPA v1.6 = 901
skip_artifacts = ['']  # Add samples that should not be moved to new workflow

artifacts = []
print '# Old queue:', len(old_queue.artifacts)

for artifact in old_queue.artifacts:
    if artifact.name not in skip_artifacts:
        print 'Move:', artifact.name
        artifacts.append(artifact)
    else:
        print 'Keep:', artifact.name

print '# Move to new workflow:', len(artifacts)