def insertMSRuns(msruns, projectId): for i in msruns: x = re.search("^sgoetze_A1*", i['name']) if x: samples = [] sample_c = clinicalSampleDAO.getClinicalSampleByClinicalSampleCode( str(int(i['sample_ref']['sampleIdRef']))) if sample_c != None: msrs = msReadySamplesDAO.getMsReadySamplesByClinicalSample( sample_c['id']) for msr in msrs: if len(msr['clinicalSamples']) == 1: new_msrun = { "runId": i['id'], "clinicalSamples": msr['clinicalSamples'], "msReadySampleId": msr['id'], "name": i['name'], "projectId": projectId, "protocolId": i['protocolId'], "instrumentId": i['instrumentId'], "sopFileName": "PHRT_Mass_Spectrometry_SOP", "instrumentMethod": "Xcalibur methods TP", "updatedDate": datetime.datetime.now(), "createdDate": datetime.datetime.now(), "workflowTag": "Sample Preparation", "description": "Generated from Excel archive", "processingPerson": "System", } print(MSRunDAO.createMsRun(new_msrun))
def insertLibGenMSRuns(projectId): frac_samples = intermediateSampleDAO.getIntermediateSamplesByProjectAndProtocolId( "fractionation_preparation", projectId) name_counter = 25 run_counter = 7 for f in frac_samples: if (re.search("^IS_MMA_library_batch-1_mix-*", f['name'])): msr_sample = msReadySamplesDAO.getMsReadySampleByIntermediateSampleId( f['id']) if (len(msr_sample) > 0): msr = msr_sample[0] new_msrun = { "runId": run_counter, "clinicalSamples": msr['clinicalSamples'], "msReadySampleId": msr['id'], "name": "PHRT_5_sgoetze_C1902_0" + str(name_counter), "projectId": projectId, "protocolId": "DDA_protocol", "instrumentId": "MS:1002877", "instrumentMethod": "Xcalibur methods TP", "sopFileName": "PHRT_Mass_Spectrometry_SOP", "updatedDate": datetime.datetime.now(), "createdDate": datetime.datetime.now(), "workflowTag": "Library Generation", "description": "Generated from Excel archive", "processingPerson": "System", } name_counter = name_counter + 1 run_counter = run_counter + 1 print(MSRunDAO.createMsRun(new_msrun))
def createMSRuns(): data = request.json msRuns = data.get('samples') responseDTO = BulkCreateResponseDTO() for i in msRuns: msReadySample = msReadySamplesDAO.getMSReadySampleByName( i['msReadySampleName']) sop = "NA" if(msReadySample != None): if i['runMode'] == "DIA": entry = artefactDAO.getArtefactById(i['SOPDIA']) if(entry != None): sop = entry['name'] elif i['runMode'] == "DDA": entry = artefactDAO.getArtefactById(i['SOPDDA']) if(entry != None): sop = entry['name'] description = "" if i['description'] != None: description = i['description'] existingMSRun = MSRunDAO.getMsRunByName(i['name']) if(existingMSRun != None): MSRunDAO.updateMSRun( existingMSRun['id'], msReadySample['id'], msReadySample['clinicalSamples'], i['instrumentId'], sop, description, i['instrumentMethod'], i['processingPerson']) responseDTO.appendOverwritten(i['name']) else: new_msrun = { "clinicalSamples": msReadySample['clinicalSamples'], "msReadySampleId": msReadySample['id'], "name": i['name'], "projectId": i['projectId'], "protocolId": i['runMode'], "instrumentId": i['instrumentId'], "sopFileName": sop, "instrumentMethod": i['instrumentMethod'], "updatedDate": datetime.datetime.now(), "createdDate": datetime.datetime.now(), "workflowTag": "Library Generation", "description": description, "processingPerson": i['processingPerson'], } new_run = MSRunDAO.createMsRun(new_msrun) responseDTO.appendCreateSuccess(i['name']) else: responseDTO.appendCreateFail(i['name']) return responseDTO.toJson(), status.HTTP_200_OK
def insertMelanomaJourney(projectId): new_sample = { "clinicalSampleCode": "FDSG23", "name": "PHRT_006_FDSG23_CPAC", "sampleCounter": 1, "projectId": projectId, "processingPerson": "System", "description": "Mock sample", "workflowTag": "Sample Preparation", "updatedDate": datetime.datetime.now(), "createdDate": datetime.datetime.now() } second_sample = { "clinicalSampleCode": "RTYD12", "name": "PHRT_006_RTYD12_CPAC", "sampleCounter": 2, "projectId": projectId, "processingPerson": "System", "description": "Mock sample", "workflowTag": "Sample Preparation", "updatedDate": datetime.datetime.now(), "createdDate": datetime.datetime.now() } cs1 = clinicalSampleDAO.createClinicalSample(new_sample) cs2 = clinicalSampleDAO.createClinicalSample(second_sample) is_sample1 = { "name": "IS_" + str(cs1['name']) + "_1", "projectId": projectId, "clinicalSamples": [cs1['id']], "workflowTag": "Sample Preparation", "protocolName": "fractionation_preparation", "sopFileName": "PHRT_Sample_Preparation_SOP", "description": "Mock sample", "processingPerson": "System", "updatedDate": datetime.datetime.now(), "createdDate": datetime.datetime.now() } is_sample2 = { "name": "IS_" + str(cs1['name']) + "_2", "projectId": projectId, "clinicalSamples": [cs1['id']], "workflowTag": "Sample Preparation", "protocolName": "fractionation_preparation", "sopFileName": "PHRT_Sample_Preparation_SOP", "description": "Mock sample", "processingPerson": "System", "updatedDate": datetime.datetime.now(), "createdDate": datetime.datetime.now() } is1 = intermediateSampleDAO.createIntermediateSample(is_sample1) is2 = intermediateSampleDAO.createIntermediateSample(is_sample2) new_msr1 = { "name": "MSR_" + is1['name'], "projectId": projectId, "clinicalSamples": is1['clinicalSamples'], "intermediateSampleId": is1['id'], "workflowTag": "Sample Preparation", "description": "Mock samples", "processingPerson": "System", "updatedDate": datetime.datetime.now(), "createdDate": datetime.datetime.now() } new_msr2 = { "name": "MSR_" + is2['name'], "projectId": projectId, "clinicalSamples": is2['clinicalSamples'], "intermediateSampleId": is2['id'], "workflowTag": "Sample Preparation", "description": "Mock samples", "processingPerson": "System", "updatedDate": datetime.datetime.now(), "createdDate": datetime.datetime.now() } msr1 = msReadySamplesDAO.createMSReadySample(new_msr1) msr2 = msReadySamplesDAO.createMSReadySample(new_msr2) new_msrun1 = { "runId": 1, "clinicalSamples": msr1['clinicalSamples'], "msReadySampleId": msr1['id'], "name": "PHRT_6_salbert_A1902_012", "projectId": projectId, "protocolId": "DIA", "instrumentId": "MS:1002523", "instrumentMethod": "Xcalibur methods TP", "sopFileName": "PHRT_Mass_Spectrometry_SOP", "updatedDate": datetime.datetime.now(), "createdDate": datetime.datetime.now(), "workflowTag": "Sample Preparation", "description": "Mock run", "processingPerson": "System" } new_msrun2 = { "runId": 2, "clinicalSamples": msr2['clinicalSamples'], "msReadySampleId": msr2['id'], "name": "PHRT_6_salbert_A1902_045", "projectId": projectId, "protocolId": "DIA", "instrumentId": "MS:1002523", "sopFileName": "PHRT_Mass_Spectrometry_SOP", "updatedDate": datetime.datetime.now(), "instrumentMethod": "Xcalibur methods TP", "createdDate": datetime.datetime.now(), "workflowTag": "Sample Preparation", "description": "Mock run", "processingPerson": "System" } run1 = MSRunDAO.createMsRun(new_msrun1) run2 = MSRunDAO.createMsRun(new_msrun2) new_spl = { "libId": 1, "clinicalSamples": is1['clinicalSamples'], "msRunIds": [run1['id'], run2['id']], "name": "PHRT_001_006_CPAC_Lib", "projectId": projectId, "protocolId": "1", "protocolName": "PHRT_Data_Analysis_SOP", "updatedDate": datetime.datetime.now(), "createdDate": datetime.datetime.now(), "specLibFilename": "PHRT_005_Spec_Lib.tsv", "sopFileName": "PHRT_Data_Analysis_SOP", "workflowTag": "Library Generation", "description": "Mock lib", "proteinDatabaseOrganism": "UP000005640", "proteinDatabaseVersion": "200812" } spl = spectralLibraryDAO.createSpectralLibrary(new_spl) new_swa = { "swathId": 1, "clinicalSamples": is1['clinicalSamples'], "msRunIds": [run1['id']], "name": "PHRT_001_006_CPAC_SWATH", "spectralLibraryId": spl['id'], "projectId": projectId, "protocolId": "1", "protocolName": "PHRT_Data_Analysis_SOP", "sopFileName": "PHRT_Data_Analysis_SOP", "proteinMatrixFileName": "PHRT_006_Protein_Matrix.tsv", "updatedDate": datetime.datetime.now(), "createdDate": datetime.datetime.now(), "workflowTag": "SWATHAnalysis", "description": "Mock swath" } print(swathAnalysisDAO.createSWATHAnalysis(new_swa))