<commit_before>/*
 * Copyright 2006-2020 The MZmine Development Team
 *
 * This file is part of MZmine.
 *
 * MZmine is free software; you can redistribute it and/or modify it under the terms of the GNU
 * General Public License as published by the Free Software Foundation; either version 2 of the
 * License, or (at your option) any later version.
 *
 * MZmine is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
 * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
 * Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with MZmine; if not,
 * write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
 * USA
 *
 * Edited and modified by <NAME> (<EMAIL>)
 */


package io.github.mzmine.modules.dataprocessing.featdet_adapchromatogrambuilder;

import io.github.mzmine.datamodel.features.FeatureList;
import io.github.mzmine.datamodel.impl.SimpleFeatureInformation;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map.Entry;
import java.util.Vector;
import javax.annotation.Nonnull;
import com.google.common.collect.Range;
import io.github.mzmine.datamodel.DataPoint;
import io.github.mzmine.datamodel.FeatureStatus;
import io.github.mzmine.datamodel.IsotopePattern;
import io.github.mzmine.datamodel.RawDataFile;
import io.github.mzmine.datamodel.Scan;
import io.github.mzmine.main.MZmineCore;
import io.github.mzmine.util.scans.ScanUtils;



/**
 * Chromatogram.
 */
public class ADAPChromatogram {
  private SimpleFeatureInformation featureInfo;

  // Data file of this chromatogram
  private RawDataFile dataFile;

  // Data points of the chromatogram (map of scan number -> m/z feature)
  // private Hashtable<Integer, DataPoint> dataPointsMap;
  private HashMap<Scan, DataPoint> dataPointsMap;

  // Chromatogram m/z, RT, height, area. The mz value will be the highest points mz value
  private double mz, rt, height, area, weightedMz;
  private Double fwhm = null, tf = null, af = null;

  // Top intensity scan, fragment scan
  private Scan representativeScan = null;
  private Scan fragmentScan = null;

  // All MS2 fragment scan numbers
  private Scan[] allMS2FragmentScanNumbers = new Scan[] {};

  // Ranges of raw data points
  private Range<Double> rawDataPointsIntensityRange, rawDataPointsMZRange;
  private Range<Float> rawDataPointsRTRange;

  // A set of scan numbers of a segment which is currently being connected
  private Vector<Scan> buildingSegment;
  // A full list of all the scan numbers as points get added
  private List<Scan> chromScanList;

  // Keep track of last added data point
  private DataPoint lastMzFeature;

  // Number of connected segments, which have been committed by
  // commitBuildingSegment()
  private int numOfCommittedSegments = 0;

  // Isotope pattern. Null by default but can be set later by deisotoping
  // method.
  private IsotopePattern isotopePattern;
  private int charge = 0;

  // <NAME>
  private double mzSum = 0;
  private int mzN = 0;
  private double weightedMzSum = 0;
  private int weightedMzN = 0;
  private double sumOfWeights = 0;

  private double highPointMZ = 0;

  // full stack of scans
  private final Scan scanNumbers[];

  public int tmp_see_same_scan_count = 0;

  // Feature list
  private FeatureList featureList;

  /**
   * Initializes this Chromatogram
   */
  public ADAPChromatogram(RawDataFile dataFile, Scan scanNumbers[]) {
    this.dataFile = dataFile;
    this.scanNumbers = scanNumbers;

    rawDataPointsRTRange = dataFile.getDataRTRange(1);

    dataPointsMap = new HashMap<Scan, DataPoint>();
    buildingSegment = new Vector<Scan>();
    chromScanList = new ArrayList<Scan>();
  }

  public double getHighPointMZ() {
    return highPointMZ;
  }

  public void setHighPointMZ(double toSet) {
    highPointMZ = toSet;
  }<commit_msg>Sort data points and scans with treemap<commit_after>/*
 * Copyright 2006-2020 The MZmine Development Team
 *
 * This file is part of MZmine.
 *
 * MZmine is free software; you can redistribute it and/or modify it under the terms of the GNU
 * General Public License as published by the Free Software Foundation; either version 2 of the
 * License, or (at your option) any later version.
 *
 * MZmine is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
 * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
 * Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with MZmine; if not,
 * write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
 * USA
 *
 * Edited and modified by <NAME> (<EMAIL>)
 */


package io.github.mzmine.modules.dataprocessing.featdet_adapchromatogrambuilder;

import io.github.mzmine.datamodel.features.FeatureList;
import io.github.mzmine.datamodel.impl.SimpleFeatureInformation;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map.Entry;
import java.util.TreeMap;
import java.util.Vector;
import javax.annotation.Nonnull;
import com.google.common.collect.Range;
import io.github.mzmine.datamodel.DataPoint;
import io.github.mzmine.datamodel.FeatureStatus;
import io.github.mzmine.datamodel.IsotopePattern;
import io.github.mzmine.datamodel.RawDataFile;
import io.github.mzmine.datamodel.Scan;
import io.github.mzmine.main.MZmineCore;
import io.github.mzmine.util.scans.ScanUtils;



/**
 * Chromatogram.
 */
public class ADAPChromatogram {
  private SimpleFeatureInformation featureInfo;

  // Data file of this chromatogram
  private RawDataFile dataFile;

  // Data points of the chromatogram (map of scan number -> m/z feature)
  // private Hashtable<Integer, DataPoint> dataPointsMap;
  private TreeMap<Scan, DataPoint> dataPointsMap;

  // Chromatogram m/z, RT, height, area. The mz value will be the highest points mz value
  private double mz, rt, height, area, weightedMz;
  private Double fwhm = null, tf = null, af = null;

  // Top intensity scan, fragment scan
  private Scan representativeScan = null;
  private Scan fragmentScan = null;

  // All MS2 fragment scan numbers
  private Scan[] allMS2FragmentScanNumbers = new Scan[] {};

  // Ranges of raw data points
  private Range<Double> rawDataPointsIntensityRange, rawDataPointsMZRange;
  private Range<Float> rawDataPointsRTRange;

  // A set of scan numbers of a segment which is currently being connected
  private Vector<Scan> buildingSegment;
  // A full list of all the scan numbers as points get added
  private List<Scan> chromScanList;

  // Keep track of last added data point
  private DataPoint lastMzFeature;

  // Number of connected segments, which have been committed by
  // commitBuildingSegment()
  private int numOfCommittedSegments = 0;

  // Isotope pattern. Null by default but can be set later by deisotoping
  // method.
  private IsotopePattern isotopePattern;
  private int charge = 0;

  // <NAME>
  private double mzSum = 0;
  private int mzN = 0;
  private double weightedMzSum = 0;
  private int weightedMzN = 0;
  private double sumOfWeights = 0;

  private double highPointMZ = 0;

  // full stack of scans
  private final Scan scanNumbers[];

  public int tmp_see_same_scan_count = 0;

  // Feature list
  private FeatureList featureList;

  /**
   * Initializes this Chromatogram
   */
  public ADAPChromatogram(RawDataFile dataFile, Scan scanNumbers[]) {
    this.dataFile = dataFile;
    this.scanNumbers = scanNumbers;

    rawDataPointsRTRange = dataFile.getDataRTRange(1);

    dataPointsMap = new TreeMap<Scan, DataPoint>();
    buildingSegment = new Vector<Scan>();
    chromScanList = new ArrayList<Scan>();
  }

  public double getHighPointMZ() {
    return highPointMZ;
  }

  public void setHighPointMZ(double toSet) {
    highPointMZ = toSet;
  }
{'fraction_non_alphanumeric': 0.08029109997613934, 'fraction_numerical': 0.00763540921021236, 'mean_word_length': 4.11470408785845, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1924988', 'n_tokens_mistral': 2611, 'n_tokens_neox': 2452, 'n_words': 864}