def __init__(self, *args, **kwargs): super(AnalysisSettingsForm, self).__init__(*args, **kwargs) # initialize choices when form instance created references = models.ReferenceGenome.objects.filter( index_version=settings.TMAP_VERSION, enabled=True) self.fields['reference'].choices = [('', 'none')] + [ (v[0], "%s (%s)" % (v[0], v[1])) for v in references.values_list('short_name', 'name') ] bedfiles = dict_bed_hotspot() self.fields['targetRegionBedFile'].choices = [('', '')] + [ (v.file, v.path.split("/")[-1].replace(".bed", "")) for v in bedfiles.get('bedFiles', []) ] self.fields['hotSpotRegionBedFile'].choices = [('', '')] + [ (v.file, v.path.split("/")[-1].replace(".bed", "")) for v in bedfiles.get('hotspotFiles', []) ] self.fields['barcodeKitName'].choices = [('', '')] + list( models.dnaBarcode.objects.order_by('name').distinct( 'name').values_list('name', 'name')) adapters = models.ThreePrimeadapter.objects.all().order_by( '-isDefault', 'name') self.fields['threePrimeAdapter'].choices = [ (v[1], "%s (%s)" % (v[0], v[1])) for v in adapters.values_list('name', 'sequence') ]
def __init__(self): super(ReferenceStepData, self).__init__() self.resourcePath = 'rundb/plan/page_plan/page_plan_reference.html' self._dependsOn = [StepNames.APPLICATION] references = list(ReferenceGenome.objects.all().filter( index_version=settings.TMAP_VERSION)) self.file_dict = dict_bed_hotspot() self.prepopulatedFields[ReferenceFieldNames.REFERENCES] = references self.prepopulatedFields[ ReferenceFieldNames.TARGET_BED_FIELS] = self.file_dict[ ReferenceFieldNames.BED_FILES] self.prepopulatedFields[ ReferenceFieldNames.HOT_SPOT_BED_FILES] = self.file_dict[ ReferenceFieldNames.HOT_SPOT_FILES] self.prepopulatedFields[ReferenceFieldNames.SHOW_HOT_SPOT_BED] = False self.prepopulatedFields[ReferenceFieldNames.REFERENCE_MISSING] = False self.prepopulatedFields[ ReferenceFieldNames.TARGED_BED_FILE_MISSING] = False self.prepopulatedFields[ ReferenceFieldNames.HOT_SPOT_BED_FILE_MISSING] = False self.savedFields[ReferenceFieldNames.REFERENCE] = None self.savedFields[ReferenceFieldNames.TARGET_BED_FILE] = None self.savedFields[ReferenceFieldNames.HOT_SPOT_BED_FILE] = None self.prepopulatedFields[ReferenceFieldNames.REFERENCE_SHORT_NAMES] = [ ref.short_name for ref in references ]
def _validate_target_bed(input, selectedTemplate, planObj): """ validate target region BED file case-insensitively with leading/trailing blanks in the input ignored """ errorMsg = None if input: bedFileDict = dict_bed_hotspot() value = input.strip() isValidated = False for bedFile in bedFileDict.get("bedFiles"): if value == bedFile.file or value == bedFile.path: isValidated = True planObj.get_easObj().targetRegionBedFile = bedFile.file # elif value.lower() == bedFile.file.lower() or value.lower() == bedFile.path.lower(): # isValidated = True # planObj.get_easObj().targetRegionBedFile = bedFile.file if not isValidated: logger.exception(format_exc()) errorMsg = input + " not found." else: planObj.get_easObj().targetRegionBedFile = "" return errorMsg
def __init__(self, sh_type): super(ReferenceStepData, self).__init__(sh_type) self.resourcePath = 'rundb/plan/page_plan/page_plan_reference.html' self._dependsOn = [StepNames.APPLICATION] references = list(ReferenceGenome.objects.all().filter(index_version=settings.TMAP_VERSION)) self.file_dict = dict_bed_hotspot() self.prepopulatedFields[ReferenceFieldNames.REFERENCES] = references self.prepopulatedFields[ReferenceFieldNames.TARGET_BED_FILES] = self.file_dict[ReferenceFieldNames.BED_FILES] self.prepopulatedFields[ReferenceFieldNames.HOT_SPOT_BED_FILES] = self.file_dict[ReferenceFieldNames.HOT_SPOT_FILES] self.prepopulatedFields[ReferenceFieldNames.SHOW_HOT_SPOT_BED] = False self.prepopulatedFields[ReferenceFieldNames.REFERENCE_MISSING] = False self.prepopulatedFields[ReferenceFieldNames.TARGET_BED_FILE_MISSING] = False self.prepopulatedFields[ReferenceFieldNames.HOT_SPOT_BED_FILE_MISSING] = False self.savedFields[ReferenceFieldNames.REFERENCE] = "" self.savedFields[ReferenceFieldNames.TARGET_BED_FILE] = "" self.savedFields[ReferenceFieldNames.HOT_SPOT_BED_FILE] = "" self.prepopulatedFields[ReferenceFieldNames.REQUIRE_TARGET_BED_FILE] = False self.prepopulatedFields[ReferenceFieldNames.REFERENCE_SHORT_NAMES] = [ref.short_name for ref in references] self.savedFields[ReferenceFieldNames.MIXED_TYPE_RNA_REFERENCE] = "" self.savedFields[ReferenceFieldNames.MIXED_TYPE_RNA_TARGET_BED_FILE] = "" self.savedFields[ReferenceFieldNames.MIXED_TYPE_RNA_HOT_SPOT_BED_FILE] = "" self.savedFields[ReferenceFieldNames.SAME_REF_INFO_PER_SAMPLE] = True self.prepopulatedFields[ReferenceFieldNames.PLAN_STATUS] = "" self.prepopulatedFields[ReferenceFieldNames.RUN_TYPE] = "" self.prepopulatedFields[ReferenceFieldNames.APPLICATION_GROUP_NAME] = "" self.sh_type = sh_type
def __init__(self, *args, **kwargs): super(AnalysisSettingsForm, self).__init__(*args, **kwargs) # initialize choices when form instance created references = models.ReferenceGenome.objects.filter( index_version=settings.TMAP_VERSION, enabled=True ) self.fields["reference"].choices = [("", "none")] + [ (v[0], "%s (%s)" % (v[0], v[1])) for v in references.values_list("short_name", "name") ] bedfiles = dict_bed_hotspot() self.fields["targetRegionBedFile"].choices = [("", "")] + [ (v.file, v.path.split("/")[-1].replace(".bed", "")) for v in bedfiles.get("bedFiles", []) ] self.fields["hotSpotRegionBedFile"].choices = [("", "")] + [ (v.file, v.path.split("/")[-1].replace(".bed", "")) for v in bedfiles.get("hotspotFiles", []) ] self.fields["barcodeKitName"].choices = [("", "")] + list( models.dnaBarcode.objects.order_by("name") .distinct("name") .values_list("name", "name") ) adapters = models.ThreePrimeadapter.objects.filter( direction="Forward", runMode="single" ).order_by("-isDefault", "chemistryType", "name") self.fields["threePrimeAdapter"].choices = [ (v[1], "%s (%s)" % (v[0], v[1])) for v in adapters.values_list("name", "sequence") ]
def __init__(self, *args, **kwargs): super(AnalysisSettingsForm, self).__init__(*args, **kwargs) # initialize choices when form instance created references = models.ReferenceGenome.objects.filter(index_version=settings.TMAP_VERSION, enabled=True) self.fields['reference'].choices= [('','none')] + [(v[0],"%s (%s)" % (v[0],v[1])) for v in references.values_list('short_name', 'name')] bedfiles = dict_bed_hotspot() self.fields['targetRegionBedFile'].choices= [('','')] + [(v.file, v.path.split("/")[-1].replace(".bed", "")) for v in bedfiles.get('bedFiles',[])] self.fields['hotSpotRegionBedFile'].choices= [('','')] + [(v.file, v.path.split("/")[-1].replace(".bed", "")) for v in bedfiles.get('hotspotFiles',[])] self.fields['barcodeKitName'].choices= [('','')]+list(models.dnaBarcode.objects.order_by('name').distinct('name').values_list('name','name')) adapters = models.ThreePrimeadapter.objects.all().order_by('-isDefault', 'name') self.fields['threePrimeAdapter'].choices= [(v[1],"%s (%s)" % (v[0],v[1])) for v in adapters.values_list('name', 'sequence')]
def _validate_hotspot_bed(input, selectedTemplate, planObj): errorMsg = None if input: bedFileDict = dict_bed_hotspot() value = input.strip() if value in bedFileDict.get("hotspotPaths") or value in bedFileDict.get("hotspotFullPaths"): for bedFile in bedFileDict.get("hotspotFiles"): if value == bedFile.file or value == bedFile.path: planObj.regionfile = bedFile.file else: logger.exception(format_exc()) errorMsg = input + " not found. " else: planObj.regionfile = "" return errorMsg
def _validate_hotspot_bed(input, selectedTemplate, planObj): errorMsg = None if input: bedFileDict = dict_bed_hotspot() value = input.strip() if value in bedFileDict.get( "hotspotPaths") or value in bedFileDict.get( "hotspotFullPaths"): for bedFile in bedFileDict.get("hotspotFiles"): if value == bedFile.file or value == bedFile.path: planObj.regionfile = bedFile.file else: logger.exception(format_exc()) errorMsg = input + " not found. " else: planObj.regionfile = "" return errorMsg
def __init__(self): super(ReferenceStepData, self).__init__() self.resourcePath = 'rundb/plan/page_plan/page_plan_reference.html' self._dependsOn = [StepNames.APPLICATION] references = list(ReferenceGenome.objects.all().filter(index_version=settings.TMAP_VERSION)) self.file_dict = dict_bed_hotspot() self.prepopulatedFields[ReferenceFieldNames.REFERENCES] = references self.prepopulatedFields[ReferenceFieldNames.TARGET_BED_FILES] = self.file_dict[ReferenceFieldNames.BED_FILES] self.prepopulatedFields[ReferenceFieldNames.HOT_SPOT_BED_FILES] = self.file_dict[ReferenceFieldNames.HOT_SPOT_FILES] self.prepopulatedFields[ReferenceFieldNames.SHOW_HOT_SPOT_BED] = False self.prepopulatedFields[ReferenceFieldNames.REFERENCE_MISSING] = False self.prepopulatedFields[ReferenceFieldNames.TARGED_BED_FILE_MISSING] = False self.prepopulatedFields[ReferenceFieldNames.HOT_SPOT_BED_FILE_MISSING] = False self.savedFields[ReferenceFieldNames.REFERENCE] = "" self.savedFields[ReferenceFieldNames.TARGET_BED_FILE] = "" self.savedFields[ReferenceFieldNames.HOT_SPOT_BED_FILE] = "" self.prepopulatedFields[ReferenceFieldNames.REFERENCE_SHORT_NAMES] = [ref.short_name for ref in references]
def validate_hotspot_bed(hotSpotRegionBedFile): """ validate hotSpot BED file case-insensitively with leading/trailing blanks in the input ignored """ errors = [] if hotSpotRegionBedFile: bedFileDict = dict_bed_hotspot() value = hotSpotRegionBedFile.strip() isValidated = False for bedFile in bedFileDict.get("hotspotFiles"): if value == bedFile.file or value == bedFile.path: isValidated = True if not isValidated: errors.append("%s hotSpotRegionBedFile is missing" % (hotSpotRegionBedFile)) logger.debug("plan_validator.validate_hotspot_bed() value=%s;" % (value)) return errors
def get_columns(selection, isBarcoded=True): columns = [] bedfiles = dict_bed_hotspot() for field_options in selection: column = get_column(field_options) field = column['field'] if not isBarcoded and field == 'barcode_name': continue if field == 'reference': for reference in ReferenceGenome.objects.filter(enabled=True): column["options"].append({ 'value': reference.short_name, 'display': '%s (%s)' % (reference.short_name, reference.name), }) if field == 'target_region_filepath': for bed in bedfiles.get('bedFiles', []): column["options"].append({ 'value': bed.file, 'display': os.path.basename(bed.file), 'reference': bed.meta['reference'] }) if field == 'hotspot_filepath': for bed in bedfiles.get('hotspotFiles', []): column["options"].append({ 'value': bed.file, 'display': os.path.basename(bed.file), 'reference': bed.meta['reference'] }) columns.append(column) return columns
def get_columns(selection, isBarcoded=True): columns = [] bedfiles = dict_bed_hotspot() for field_options in selection: column = get_column(field_options) field = column["field"] if not isBarcoded and field == "barcode_name": continue if field == "reference": for reference in ReferenceGenome.objects.filter(enabled=True): column["options"].append({ "value": reference.short_name, "display": "%s (%s)" % (reference.short_name, reference.name), }) if field == "target_region_filepath": for bed in bedfiles.get("bedFiles", []): column["options"].append({ "value": bed.file, "display": os.path.basename(bed.file), "reference": bed.meta["reference"], }) if field == "hotspot_filepath": for bed in bedfiles.get("hotspotFiles", []): column["options"].append({ "value": bed.file, "display": os.path.basename(bed.file), "reference": bed.meta["reference"], }) columns.append(column) return columns
def get_columns(selection, isBarcoded=True): columns = [] bedfiles = dict_bed_hotspot() for field_options in selection: column = get_column(field_options) field = column['field'] if not isBarcoded and field =='barcode_name': continue if field == 'reference': for reference in ReferenceGenome.objects.filter(enabled=True): column["options"].append({ 'value': reference.short_name, 'display':'%s (%s)' % (reference.short_name, reference.name), }) if field == 'target_region_filepath': for bed in bedfiles.get('bedFiles', []): column["options"].append({ 'value': bed.file, 'display': os.path.basename(bed.file), 'reference': bed.meta['reference'] }) if field == 'hotspot_filepath': for bed in bedfiles.get('hotspotFiles', []): column["options"].append({ 'value': bed.file, 'display': os.path.basename(bed.file), 'reference': bed.meta['reference'] }) columns.append(column) return columns
def _get_base_planTemplate_data(isForTemplate): data = {} #per requirement, we want to display Generic Sequencing as the last entry in the selection list data["runTypes"] = list(RunType.objects.all().exclude(runType = "GENS").order_by('nucleotideType', 'runType')) data["secondaryRunTypes"] = list(RunType.objects.filter(runType = "GENS")) data["barcodes"] = list(dnaBarcode.objects.values('name').distinct().order_by('name')) ##barcodeKitNames = dnaBarcode.objects.values_list('name', flat=True).distinct().order_by('name') ##for barcodeKitName in barcodeKitNames: ## data[barcodeKitName] = dnaBarcode.objects.filter(name=barcodeKitName).order_by('index') data["barcodeKitInfo"] = list(dnaBarcode.objects.all().order_by('name', 'index')) references = list(ReferenceGenome.objects.all().filter(index_version=settings.TMAP_VERSION)) data["references"] = references data["referenceShortNames"] = [ref.short_name for ref in references] data.update(dict_bed_hotspot()) data["seqKits"] = KitInfo.objects.filter(kitType='SequencingKit', isActive=True).order_by("name") data["libKits"] = KitInfo.objects.filter(kitType='LibraryKit', isActive=True).order_by("name") data["variantfrequencies"] = VariantFrequencies.objects.all().order_by("name") #the entry marked as the default will be on top of the list data["forwardLibKeys"] = LibraryKey.objects.filter(direction='Forward', runMode='single').order_by('-isDefault', 'name') data["forward3Adapters"] = ThreePrimeadapter.objects.filter(direction='Forward', runMode='single').order_by('-isDefault', 'name') #pairedEnd does not have special forward library keys #for TS-4669: remove paired-end from wizard, if there are no active PE lib kits, do not prepare pe keys or adapters peLibKits = KitInfo.objects.filter(kitType='LibraryKit', runMode='pe', isActive=True) if (peLibKits.count() > 0): data["peForwardLibKeys"] = LibraryKey.objects.filter(direction='Forward').order_by('-isDefault', 'name') data["peForward3Adapters"] = ThreePrimeadapter.objects.filter(direction='Forward', runMode='pe').order_by('-isDefault', 'name') data["reverseLibKeys"] = LibraryKey.objects.filter(direction='Reverse').order_by('-isDefault', 'name') data["reverse3Adapters"] = ThreePrimeadapter.objects.filter(direction='Reverse').order_by('-isDefault', 'name') else: data["peForwardLibKeys"] = None data["peForward3Adapters"] = None data["reverseLibKeys"] = None data["reverse3Adapters"] = None #chip types #note: customer-facing chip names are no longer unique data['chipTypes'] = list(Chip.objects.filter(isActive=True).order_by('description', 'name').distinct('description')) #QC data['qcTypes'] = list(QCType.objects.all().order_by('qcName')) #project data['projects'] = list(Project.objects.filter(public=True).order_by('name')) #templating kit selection data["templateKits"] = KitInfo.objects.filter(kitType='TemplatingKit', isActive=True).order_by("name") #control sequence kit selection data["controlSeqKits"] = KitInfo.objects.filter(kitType='ControlSequenceKit', isActive=True).order_by("name") #ionChef kit selection data["ionChefKits"] = KitInfo.objects.filter(kitType='IonChefPrepKit', isActive=True).order_by("name") #pairedEnd library adapter selection #for TS-4669: remove paired-end from wizard, if there are no active PE seq kits, do not prepare pe keys or adapters if (peLibKits.count() > 0): data["pairedEndLibAdapters"] = KitInfo.objects.filter(kitType='AdapterKit', runMode="pe", isActive=True).order_by('name') else: data["pairedEndLibAdapters"] = None #samplePrep kits data["samplePrepKits"] = KitInfo.objects.filter(kitType='SamplePrepKit', isActive=True).order_by('name') data.update(_dict_IR_plugins_uploaders(isForTemplate)) #to allow data entry for multiple non-barcoded samples at the plan wizard data['nonBarcodedSamples_irConfig_loopCounter'] = [i + 1 for i in range(20)] return data
def __init__(self, attrs=None, choices=()): super(bedfiles_Select, self).__init__(attrs=attrs, choices=choices) bedfiles = dict_bed_hotspot() self.bedfiles = bedfiles.get(attrs['name'],[])
def _get_base_planTemplate_data(isForTemplate): data = {} #per requirement, we want to display Generic Sequencing as the last entry in the selection list data["runTypes"] = list(RunType.objects.all().exclude( runType="GENS").order_by('nucleotideType', 'runType')) data["secondaryRunTypes"] = list(RunType.objects.filter(runType="GENS")) data["barcodes"] = list( dnaBarcode.objects.values('name').distinct().order_by('name')) ##barcodeKitNames = dnaBarcode.objects.values_list('name', flat=True).distinct().order_by('name') ##for barcodeKitName in barcodeKitNames: ## data[barcodeKitName] = dnaBarcode.objects.filter(name=barcodeKitName).order_by('index') data["barcodeKitInfo"] = list(dnaBarcode.objects.all().order_by( 'name', 'index')) references = list(ReferenceGenome.objects.all().filter( index_version=settings.TMAP_VERSION)) data["references"] = references data["referenceShortNames"] = [ref.short_name for ref in references] data.update(dict_bed_hotspot()) data["seqKits"] = KitInfo.objects.filter(kitType='SequencingKit', isActive=True).order_by("name") data["libKits"] = KitInfo.objects.filter(kitType='LibraryKit', isActive=True).order_by("name") data["variantfrequencies"] = VariantFrequencies.objects.all().order_by( "name") #the entry marked as the default will be on top of the list data["forwardLibKeys"] = LibraryKey.objects.filter( direction='Forward', runMode='single').order_by('-isDefault', 'name') data["forward3Adapters"] = ThreePrimeadapter.objects.filter( direction='Forward', runMode='single').order_by('-isDefault', 'name') #pairedEnd does not have special forward library keys #for TS-4669: remove paired-end from wizard, if there are no active PE lib kits, do not prepare pe keys or adapters peLibKits = KitInfo.objects.filter(kitType='LibraryKit', runMode='pe', isActive=True) if (peLibKits.count() > 0): data["peForwardLibKeys"] = LibraryKey.objects.filter( direction='Forward').order_by('-isDefault', 'name') data["peForward3Adapters"] = ThreePrimeadapter.objects.filter( direction='Forward', runMode='pe').order_by('-isDefault', 'name') data["reverseLibKeys"] = LibraryKey.objects.filter( direction='Reverse').order_by('-isDefault', 'name') data["reverse3Adapters"] = ThreePrimeadapter.objects.filter( direction='Reverse').order_by('-isDefault', 'name') else: data["peForwardLibKeys"] = None data["peForward3Adapters"] = None data["reverseLibKeys"] = None data["reverse3Adapters"] = None #chip types #note: customer-facing chip names are no longer unique data['chipTypes'] = list( Chip.objects.filter(isActive=True).order_by( 'description', 'name').distinct('description')) #QC data['qcTypes'] = list(QCType.objects.all().order_by('qcName')) #project data['projects'] = list( Project.objects.filter(public=True).order_by('name')) #templating kit selection data["templateKits"] = KitInfo.objects.filter( kitType='TemplatingKit', isActive=True).order_by("name") #control sequence kit selection data["controlSeqKits"] = KitInfo.objects.filter( kitType='ControlSequenceKit', isActive=True).order_by("name") #ionChef kit selection data["ionChefKits"] = KitInfo.objects.filter( kitType='IonChefPrepKit', isActive=True).order_by("name") #pairedEnd library adapter selection #for TS-4669: remove paired-end from wizard, if there are no active PE seq kits, do not prepare pe keys or adapters if (peLibKits.count() > 0): data["pairedEndLibAdapters"] = KitInfo.objects.filter( kitType='AdapterKit', runMode="pe", isActive=True).order_by('name') else: data["pairedEndLibAdapters"] = None #samplePrep kits data["samplePrepKits"] = KitInfo.objects.filter( kitType='SamplePrepKit', isActive=True).order_by('name') data.update(_dict_IR_plugins_uploaders(isForTemplate)) #to allow data entry for multiple non-barcoded samples at the plan wizard data['nonBarcodedSamples_irConfig_loopCounter'] = [ i + 1 for i in range(20) ] return data