HighestDataPointConnector(double minimumTimeSpan, double minimumHeight, MZTolerance mzTolerance) { this.mzTolerance = mzTolerance; this.minimumHeight = minimumHeight; this.minimumTimeSpan = minimumTimeSpan; // Create the data structure dataPoints = MSDKObjectBuilder.getMsSpectrumDataPointList(); // We use LinkedHashSet to maintain a reproducible ordering. If we use // plain HashSet, the resulting peak list row IDs will have different // order every time the method is invoked. buildingChromatograms = new LinkedHashSet<BuildingChromatogram>(); connectedChromatograms = new LinkedHashSet<BuildingChromatogram>(); }
/** * <p> * Constructor for MatchAlignerMethod. * </p> * * @param featureTables a {@link java.util.List} object. * @param mzTolerance an objectt * @param rtTolerance a {@link io.github.msdk.util.tolerances.RTTolerance} object. */ public JoinAlignerMethod(@Nonnull List<FeatureTable> featureTables, @Nonnull MzTolerance mzTolerance, @Nonnull RTTolerance rtTolerance) { this.featureTables = featureTables; this.mzTolerance = mzTolerance; this.rtTolerance = rtTolerance; // Make a new feature table this.result = new SimpleFeatureTable(); }
/** {@inheritDoc} */ @Override public MsFunction getMsFunction() { Integer msLevel = 1; String value = getCVValue(MzMLCV.cvMSLevel); if (!Strings.isNullOrEmpty(value)) msLevel = Integer.parseInt(value); return MSDKObjectBuilder.getMsFunction(msLevel); }
final MsFunction msFunction = MSDKObjectBuilder.getMsFunction(1); MsScan scan = MSDKObjectBuilder.getMsScan(dataStore, scanNumber, msFunction); .getChromatographyInfo1D(SeparationType.UNKNOWN, scanRetentionTimes[scanIndex]);
private void addCommonColumns(@Nonnull FeatureTable featureTable) { // Common columns // Only add common columns if the feature table is empty if (featureTable.getColumns().isEmpty()) { FeatureTableColumn<Integer> idColumn = MSDKObjectBuilder.getIdFeatureTableColumn(); FeatureTableColumn<Double> mzColumn = MSDKObjectBuilder.getMzFeatureTableColumn(); FeatureTableColumn<Double> ppmColumn = MSDKObjectBuilder.getPpmFeatureTableColumn(); FeatureTableColumn<Float> rtColumn = MSDKObjectBuilder.getRetentionTimeFeatureTableColumn(); FeatureTableColumn<List<SimpleIonAnnotation>> ionAnnotationColumn = MSDKObjectBuilder.getIonAnnotationFeatureTableColumn(); featureTable.addColumn(idColumn); featureTable.addColumn(mzColumn); featureTable.addColumn(ppmColumn); featureTable.addColumn(rtColumn); featureTable.addColumn(ionAnnotationColumn); } }
private static FeatureTableRow copyRow(@Nonnull FeatureTableRow row, @Nonnull FeatureTable result) { // Create a new row with the common feature data final FeatureTableRow newRow = MSDKObjectBuilder.getFeatureTableRow(result, row.getId()); FeatureTableUtil.copyCommonValues(row, newRow, false); // Copy the feature data for the samples for (Sample sample : row.getFeatureTable().getSamples()) { FeatureTableUtil.copyFeatureValues(row, newRow, sample); } return newRow; }
@Nullable @SuppressWarnings("null") private FeatureTableColumn<?> getFeatureTableColumn( @Nonnull String mzTabColumnName, @Nonnull Sample sample, int msRunKey) { if (mzTabColumnName.contains("[" + msRunKey + "]_")) { String[] nameArray = mzTabColumnName.split("]_"); @Nonnull String name = nameArray[1]; ColumnName columnName = mzTabNameToColumnName(name); if (columnName == null) { return MSDKObjectBuilder.getFeatureTableColumn(name, String.class, sample); } else { return MSDKObjectBuilder.getFeatureTableColumn(columnName, sample); } } else { return null; } }
/** {@inheritDoc} */ @SuppressWarnings("null") @Override public RawDataFile execute() throws MSDKException { logger.info("Started parsing file " + sourceFile); String fileName = sourceFile.getName(); newRawFile = MSDKObjectBuilder.getRawDataFile(fileName, sourceFile, fileType, dataStore); saxHandler = new MzDataSaxHandler(newRawFile, dataStore); SAXParserFactory factory = SAXParserFactory.newInstance(); try { SAXParser saxParser = factory.newSAXParser(); saxParser.parse(sourceFile, saxHandler); } catch (Exception e) { if (canceled) return null; else throw new MSDKException(e); } logger.info("Finished parsing " + sourceFile); return newRawFile; }
/** {@inheritDoc} */ @Override @Nonnull public Chromatogram clone(@Nonnull DataPointStore newStore) { Preconditions.checkNotNull(newStore); Chromatogram newChromatogram = MSDKObjectBuilder.getChromatogram( newStore, getChromatogramNumber(), getChromatogramType(), getSeparationType()); final ChromatogramDataPointList dataPointList = MSDKObjectBuilder .getChromatogramDataPointList(); getDataPoints(dataPointList); final RawDataFile rawDataFile2 = getRawDataFile(); if (rawDataFile2 != null) { newChromatogram.setRawDataFile(rawDataFile2); } newChromatogram.getIsolations().addAll(getIsolations()); newChromatogram.setDataPoints(dataPointList); return newChromatogram; }
RowVsRowScore(FeatureTableRow featureTableRow, SimpleFeatureTableRow alignedRow, double mzMaxDiff, double mzWeight, double rtMaxDiff, double rtWeight) { this.featureTableRow = featureTableRow; this.alignedRow = alignedRow; // Get m/z and RT values Double mz1 = featureTableRow.getMz(); Double mz2 = alignedRow.getMz(); Float rt1 = featureTableRow.getRT(); Float rt2 = alignedRow.getRT(); // Calculate difference between m/z double mzDiff = 999; if (mz1 != null && mz2 != null) mzDiff = Math.abs(mz1 - mz2); // Calculate difference between RT values double rtDiff = 999; if (rt1 != null && rt2 != null) rtDiff = Math.abs(rt1 - rt2); score = ((1 - mzDiff / mzMaxDiff) * mzWeight) + ((1 - rtDiff / rtMaxDiff) * rtWeight); }
result = MSDKObjectBuilder.getFeatureTable(featureTable.getName() + nameSuffix, dataStore);
/** {@inheritDoc} */ @Override public RawDataFile execute() throws MSDKException { logger.info("Started centroiding file " + rawDataFile.getName()); // Create a new raw data file result = new SimpleRawDataFile(rawDataFile.getName(), rawDataFile.getOriginalFile(), rawDataFile.getRawDataFileType()); List<MsScan> scans = rawDataFile.getScans(); totalScans = scans.size(); for (MsScan scan : scans) { if (canceled) return null; MsScan newScan = centroidingAlgorithm.centroidScan(scan); // Add the new scan to the created raw data file if (newScan != null) result.addScan(newScan); processedScans++; } logger.info("Finished centroiding file " + rawDataFile.getName()); return result; }
int addMaxDatumFromScans(SpotByProbes s, SimpleChromatogram peak) { int i, j; int adds = 0; for (i = s.minScan; i <= s.maxScan; i++) { Datum[] di = roi[i]; if (di != null && di.length > 0) { Datum max = new Datum(new DataPoint(0, -1), 0, new DataPoint(0, -1)); int idx = findFirstMass(s.minMZ, di); for (j = idx; j < di.length && di[j].mz <= s.maxMZ; j++) { Datum d = di[j]; if (d.spotId == s.spotId) { if (d.intensity > max.intensity && d.mz >= s.minMZ && d.intensity > minimumHeight) { max = d; } } } if (max.intensity > 0) { adds++; peak.addDataPoint(scans.get(i).getRetentionTime(), max.mzOriginal, new Float(max.intensityOriginal)); } } } return adds; }
newScan.setDataPoints(mzBuffer, intensityBuffer, 0); return newScan; newScan.setDataPoints(mzBuffer, intensityBuffer, newNumOfDataPoints);
@Nonnull MsFunction extractMsFunction(Spectrum spectrum) { Integer msLevel = 1; // Browse the spectrum parameters List<CVParam> cvParams = spectrum.getCvParam(); if (cvParams != null) { for (CVParam param : cvParams) { String accession = param.getAccession(); String value = param.getValue(); if ((accession == null) || (value == null)) continue; // MS level MS:1000511 if (accession.equals("MS:1000511")) { msLevel = Integer.parseInt(value); } } } return MSDKObjectBuilder.getMsFunction(msLevel); }
/** * <p> * Constructor for FeatureNormalizationByCompoundMethod. * </p> * * @param featureTable a {@link io.github.msdk.datamodel.featuretables.FeatureTable} object. * @param normalizationType a * {@link io.github.msdk.features.normalization.compound.NormalizationType} object. * @param internalStandardRows a {@link java.util.List} object of * {@link io.github.msdk.datamodel.featuretables.FeatureTableRow} . * @param mzRtWeight a {@link java.lang.Integer} object. */ public FeatureNormalizationByCompoundMethod(@Nonnull FeatureTable featureTable, @Nonnull NormalizationType normalizationType, @Nonnull List<FeatureTableRow> internalStandardRows, @Nonnull Integer mzRtWeight) { this.featureTable = featureTable; this.normalizationType = normalizationType; this.mzRtWeight = mzRtWeight; this.internalStandardRows = internalStandardRows; // Make a copy of the feature table result = new SimpleFeatureTable(); }
/** {@inheritDoc} */ @Override public @Nonnull MsScan centroidScan(@Nonnull MsScan inputScan) { // Copy all scan properties this.newScan = MsScanUtil.clone(inputScan, false); // Load data points mzBuffer = inputScan.getMzValues(); intensityBuffer = inputScan.getIntensityValues(); numOfDataPoints = inputScan.getNumberOfDataPoints(); newNumOfDataPoints = 0; // If there are no data points, just return the scan if (numOfDataPoints == 0) { newScan.setDataPoints(mzBuffer, intensityBuffer, 0); return newScan; } // Run the recursive search algorithm recursiveThreshold(0, numOfDataPoints - 1, 0); // Store the new data points newScan.setDataPoints(newMzBuffer, newIntensityBuffer, newNumOfDataPoints); return newScan; }
newScan.setDataPoints(mzBuffer, intensityBuffer, 0); return newScan; newScan.setDataPoints(mzBuffer, intensityBuffer, newNumOfDataPoints);
/** {@inheritDoc} */ @Override public @Nonnull MsScan centroidScan(@Nonnull MsScan inputScan) { // Copy all scan properties SimpleMsScan newScan = MsScanUtil.clone(inputScan, false); // Load data points double[] mzBuffer = inputScan.getMzValues(); float[] intensityBuffer = inputScan.getIntensityValues(); int numOfDataPoints = inputScan.getNumberOfDataPoints(); // If there are no data points, just return the scan if (numOfDataPoints == 0) { newScan.setDataPoints(mzBuffer, intensityBuffer, 0); return newScan; } float[] cwtDataPoints = performCWT(intensityBuffer, numOfDataPoints, scaleLevel, waveletWindow); int newNumOfDataPoints = extractMzPeaks(cwtDataPoints, mzBuffer, intensityBuffer); // Store the new data points newScan.setDataPoints(mzBuffer, intensityBuffer, newNumOfDataPoints); return newScan; }