/* Author: Daniel Cerne Date: 2015-11-03 Script Purpose: Identify all wells that could be contaminating any well within a ESI plate as measured by ESI Required Columns(Note): ESIBarcode MfgID ESIWellPosition ESICalcMW PeakMass Output: Column named "Within Plate Possible Contaminants" that lists all potential contaminant wells (if any) within a plate for the observed mass as a string Comments: */ Names Default To Here( 1 ); Peak Table = Current Data Table(); // // Get list of ESI Barcodes for later use // ESI Barcode List is a named list containing all the ESI barcodes in the original table, one instance per barcode // ESISummary = Peak Table << Summary( invisible, group( :ESIBarcode ) ); ESIBarcodeList = :ESIBarcode << Get Values; Close( ESISummary, no save ); // // Switch back to original peak table to get peak information, summarize by ManID, Well Position and CalcWeight // for each ESI Plate. Make an associative array to easily find positional information // Current Data Table( Peak Table ); Peak Table << New Column("Within Plate Possible Contaminants",Character); For( q=1, q<=N Row(ESIBarcodeList),q++, ESIBarcodeRowNumbers = Peak Table << Select Where( :ESIBarcode == ESIBarcodeList[q] ); ESIBarcodeSubset = Peak Table << Subset( Selected Rows ); ESIBarcodeSubset << Summary( invisible, Group( :MfgID, :ESIWellPosition, :ESICalcMW ) ); ESIManIDs = :MfgID << Get Values; ESIWellIDS = :ESIWellPosition << Get Values; ESIESICalcW = :ESICalcMW << Get Values; ESIOligoInfo = Associative Array(); ESIOligoInfo["ManID"] = ESIManIDs; ESIOligoInfo["WellIDs"] = ESIWellIDS; ESIOligoInfo["CalcWeights"] = ESIESICalcW; Close( ESIBarcodeSubset, no save ); // Show(ESIOligoInfo); // // Back to original Peak table to get all the observed peaks for given ESIID, stored in list variable PeakMassesList. // Iterates through the list to compare all calculated masses to a given peak recorded by ESI. Any peak within 5 daltons // that isn't FLP in the well being examined will be flagged as a potential contaminant. // // Populates a list with all the potential contaminant wells. Cleans up the list to a more user friendly string. // Current Data Table( Peak Table ); ESIBarcodeRowNumbers = Peak Table << Select Where( :ESIBarcode == ESIBarcodeList[q] ); TableRowsESI = Peak Table << Get selected rows(); TableRowsESI = As List( TableRowsESI ); PeakMassesList = List(); RowsofESI = N Items( TableRowsESI ); For( i = 1, i <= RowsofESI, i++, RowNum = TableRowsESI[i]; RowMass = :PeakMass[RowNum]; Insert Into(PeakMassesList,RowMass,RowNum); ); // Show(N ITems(PeakMassesList)); // Show(PeakMassesList); // // Compare PeakMass in row to all possible calculated weights in a given ESI // For( g=1, g<=N Items(PeakMassesList),g++, PeakMassRow = PeakMassesList[g]; CalcMassesFromPeak = Round(ESIOligoInfo["CalcWeights"]- PeakMassRow,2); // Show(N Rows(CalcMassesFromPeak)); // Show(CalcMassesFromPeak); flag = loc(-5<=CalcMassesFromPeak<=5); // Show(flag); y= NRow(flag); WellLookup = ESIOligoInfo["WellIDs"]; if(y!=0,FlaggedWells = WellLookup[flag],FlaggedWells = ""); // Show(FlaggedWells); RowPos = TableRowsESI[g]; Itself = :ESIWellPosition[RowPos]; // Show(Itself); StillFlagged = If(Itself == FlaggedWells, "", FlaggedWells); // Show(StillFlagged); If (Is list(StillFlagged), Remove From(StillFlagged,Contains(StillFlagged, Itself,1)),StillFlagged); ContaminatingWells = List(); If(Is List(StillFlagged)==0, Insert Into(ContaminatingWells, StillFlagged,1),ContaminatingWells = StillFlagged); ConWellString =""; For( h=1, h<=N Items(ContaminatingWells),h++, ConWell = ContaminatingWells[h]; ConWell = Char(ConWell); ConWellString = ConWellString||"-"||ConWell; ); ConWellString = Right( ConWellString, Length( ConWellString ) - 1 ); // Show(ContaminatingWells); // Show(ConWellString); :Within Plate Possible Contaminants[RowPos] = ConWellString; ); ); // Fin.