Пример #1
0
int main(int argc, const char** argv)
{
  if (argc < 2) return 1;

  // the path to the data should be given on the command line
  String tutorial_data_path(argv[1]);

  TOFCalibration ec;
  PeakMap exp_raw, calib_exp;
  MzMLFile mzml_file;
  mzml_file.load(tutorial_data_path + "/data/Tutorial_TOFCalibration_peak.mzML", calib_exp);
  mzml_file.load(tutorial_data_path + "/data/Tutorial_TOFCalibration_raw.mzML", exp_raw);

  vector<double> ref_masses;
  TextFile ref_file;
  ref_file.load(tutorial_data_path + "/data/Tutorial_TOFCalibration_masses.txt", true);
  for (TextFile::ConstIterator iter = ref_file.begin(); iter != ref_file.end(); ++iter)
  {
    ref_masses.push_back(String(iter->c_str()).toDouble());
  }

  std::vector<double> ml1;
  ml1.push_back(418327.924993827);

  std::vector<double> ml2;
  ml2.push_back(253.645187196031);

  std::vector<double> ml3;
  ml3.push_back(-0.0414243465397252);

  ec.setML1s(ml1);
  ec.setML2s(ml2);
  ec.setML3s(ml3);

  Param param;
  param.setValue("PeakPicker:peak_width", 0.1);
  ec.setParameters(param);
  ec.pickAndCalibrate(calib_exp, exp_raw, ref_masses);

  return 0;
} //end of main
Пример #2
0
  ExitCodes main_(int, const char**)
  {

    //-------------------------------------------------------------
    // parameter handling
    //-------------------------------------------------------------

    String in = getStringOption_("in");
    String out = getStringOption_("out");
    String in_calib = getStringOption_("ext_calibrants");
    String ref = getStringOption_("ref_masses");
    String conv = getStringOption_("tof_const");
    //-------------------------------------------------------------
    // init TOFCalibration
    //-------------------------------------------------------------

    TOFCalibration calib;
    calib.setLogType(log_type_);
    Param param = getParam_().copy("algorithm:", true);
    calib.setParameters(param);
    //-------------------------------------------------------------
    // loading input
    //-------------------------------------------------------------
    MSExperiment<Peak1D> ms_exp_calib, ms_exp_raw;
    MzMLFile mz_data_file;
    mz_data_file.setLogType(log_type_);
    mz_data_file.load(in_calib, ms_exp_calib);
    mz_data_file.load(in, ms_exp_raw);

    vector<double> ref_masses;
    TextFile ref_file;
    ref_file.load(ref, true);

    for (TextFile::ConstIterator iter = ref_file.begin(); iter != ref_file.end(); ++iter)
    {
      ref_masses.push_back(String(iter->c_str()).toDouble());
    }
    TextFile const_file;
    const_file.load(conv, true);
    std::vector<String> vec;
    TextFile::ConstIterator iter = const_file.begin();
    iter->split('\t', vec);

    std::vector<double> ml1, ml2, ml3;
    ml1.push_back(String(vec[0].c_str()).toDouble());
    ml2.push_back(String(vec[1].c_str()).toDouble());
    if (vec.size() == 3)
    {
      ml3.push_back(String(vec[2].c_str()).toDouble());
    }
    ++iter;

    for (; iter != const_file.end(); ++iter)
    {
      iter->split('\t', vec);
      ml1.push_back(String(vec[0].c_str()).toDouble());
      ml2.push_back(String(vec[1].c_str()).toDouble());
      if (vec.size() == 3)
      {
        ml3.push_back(String(vec[2].c_str()).toDouble());
      }
    }

    if (ml1.size() != 1 &&  ml1.size() != ms_exp_calib.size())
    {
      writeLog_("Incorrect number of calibration constants given. Aborting!");
      return INPUT_FILE_CORRUPT;
    }
    calib.setML1s(ml1);
    calib.setML2s(ml2);
    if (!ml3.empty()) calib.setML3s(ml3);

    //-------------------------------------------------------------
    // perform calibration
    //-------------------------------------------------------------
    if (getFlag_("peak_data"))
    {
      calib.calibrate(ms_exp_calib, ms_exp_raw, ref_masses);
    }
    else
    {
      calib.pickAndCalibrate(ms_exp_calib, ms_exp_raw, ref_masses);
    }

    //-------------------------------------------------------------
    // writing output
    //-------------------------------------------------------------

    //annotate output with data processing info
    addDataProcessing_(ms_exp_raw, getProcessingInfo_(DataProcessing::CALIBRATION));

    mz_data_file.store(out, ms_exp_raw);

    return EXECUTION_OK;
  }