Ejemplo n.º 1
0
PPM Spectrum::getPeakWidth( Dimension d ) const
{
	SpectrumType* t = getType();
	if( t == 0 )
		return 0;
	return t->getPeakWidth( mapToType( d ) );
}
Ejemplo n.º 2
0
SpinLabel Spectrum::getKeyLabel(Dimension d) const
{
	SpectrumType* t = getType();
	if( t == 0 )
		return SpinLabel();
	return t->getKeyLabel( mapToType( d ) );
}
Ejemplo n.º 3
0
int Spectrum::getNoesyDir(Dimension a, Dimension b) const
{
	SpectrumType* t = getType();
	if( t == 0 )
		return SpectrumType::NoNoesy;
	else
        return t->getNoesyDir( mapToType( a ), mapToType( b ) );
}
Ejemplo n.º 4
0
bool Spectrum::hasNoesy() const
{
	SpectrumType* t = getType();
	if( t == 0 )
		return false;
	else
		return t->hasNoesy();
}
Ejemplo n.º 5
0
bool Spectrum::isNoesy(Dimension a ) const
{
	SpectrumType* t = getType();
	if( t == 0 )
		return false;
	else
		return t->isNoesy( mapToType( a ) );
}
Ejemplo n.º 6
0
const char* Spectrum::getDimName(Dimension d) const
{
	SpectrumType* t = getType();
	if( t )
		return t->getName( mapToType( d ) ).data();
	else
		return getScale( d ).getColor().getIsoLabel();
}
Ejemplo n.º 7
0
AtomType Spectrum::getColor(Dimension d) const
{
	SpectrumType* t = getType();
	if( t )
		return t->getColor( mapToType( d ) );
	else
		return getScale( d ).getColor();
}
Ejemplo n.º 8
0
 void consumeSpectrum(SpectrumType & s) override
 {
   for (Size i = 0; i < s.size(); i++) 
   { 
     TIC += s[i].getIntensity(); 
   }
   nr_peaks += s.size();
   nr_spectra++;
 }
Ejemplo n.º 9
0
  void MSDataSqlConsumer::consumeSpectrum(SpectrumType & s)
  {
    spectra_.push_back(s);
    s.clear(false);
    if (full_meta_) peak_meta_.addSpectrum(s);

    if (spectra_.size() >= flush_after_) {flush();}
  }
Ejemplo n.º 10
0
	double MelFilter::Apply(const SpectrumType& dataSpectrum)
	{
		double value = 0.0;
		int N = dataSpectrum.size();
		for (int i = 0; i < N; ++i)
			value += std::abs(dataSpectrum[i]) * m_spectrum[i];

		return value;
	}
Ejemplo n.º 11
0
 /**
  * Returns a single value computed by multiplying signal spectrum with
  * Mel filter spectrum and summing all the products.
  *
  * @param dataSpectrum complex signal spectrum
  * @return dot product of the spectra
  */
 double MelFilter::apply(const SpectrumType& dataSpectrum) const
 {
     double value = 0.0;
     const std::size_t N = dataSpectrum.size();
     // iteration over first half of the spectrum
     for (std::size_t i = 0; i < N / 2 - 1; ++i)
     {
         value += std::abs(dataSpectrum[i]) * m_spectrum[i];
     }
     return value;
 }
Ejemplo n.º 12
0
const SpinLabelSet& Spectrum::getSpinLabels(Dimension d) const
{
	SpectrumType* t = getType();
	assert( t );
	return t->getLabels( d );
}
Ejemplo n.º 13
0
  static void deisotopeAndSingleChargeMSSpectrum_(SpectrumType& in, Int min_charge, Int max_charge, double fragment_tolerance, bool fragment_unit_ppm, bool keep_only_deisotoped = false, Size min_isopeaks = 3, Size max_isopeaks = 10, bool make_single_charged = true)
  {
    if (in.empty())
    {
      return;
    }

    SpectrumType old_spectrum = in;

    // determine charge seeds and extend them
    vector<Size> mono_isotopic_peak(old_spectrum.size(), 0);
    vector<Int> features(old_spectrum.size(), -1);
    Int feature_number = 0;

    for (Size current_peak = 0; current_peak != old_spectrum.size(); ++current_peak)
    {
      double current_mz = old_spectrum[current_peak].getPosition()[0];

      for (Int q = max_charge; q >= min_charge; --q)   // important: test charge hypothesis from high to low
      {
        // try to extend isotopes from mono-isotopic peak
        // if extension larger then min_isopeaks possible:
        //   - save charge q in mono_isotopic_peak[]
        //   - annotate all isotopic peaks with feature number
        if (features[current_peak] == -1)   // only process peaks which have no assigned feature number
        {
          bool has_min_isopeaks = true;
          vector<Size> extensions;
          for (Size i = 0; i < max_isopeaks; ++i)
          {
            double expected_mz = current_mz + i * Constants::C13C12_MASSDIFF_U / q;
            Size p = old_spectrum.findNearest(expected_mz);
            double tolerance_dalton = fragment_unit_ppm ? fragment_tolerance * old_spectrum[p].getPosition()[0] * 1e-6 : fragment_tolerance;
            if (fabs(old_spectrum[p].getPosition()[0] - expected_mz) > tolerance_dalton)   // test for missing peak
            {
              if (i < min_isopeaks)
              {
                has_min_isopeaks = false;
              }
              break;
            }
            else
            {
              // TODO: include proper averagine model filtering. for now start at the second peak to test hypothesis
              Size n_extensions = extensions.size();
              if (n_extensions != 0)
              {
                if (old_spectrum[p].getIntensity() > old_spectrum[extensions[n_extensions - 1]].getIntensity())
                {
                  if (i < min_isopeaks)
                  {
                    has_min_isopeaks = false;
                  }
                  break;
                }
              }

              // averagine check passed
              extensions.push_back(p);
            }
          }

          if (has_min_isopeaks)
          {
            //cout << "min peaks at " << current_mz << " " << " extensions: " << extensions.size() << endl;
            mono_isotopic_peak[current_peak] = q;
            for (Size i = 0; i != extensions.size(); ++i)
            {
              features[extensions[i]] = feature_number;
            }
            feature_number++;
          }
        }
      }
    }

    in.clear(false);
    for (Size i = 0; i != old_spectrum.size(); ++i)
    {
      Int z = mono_isotopic_peak[i];
      if (keep_only_deisotoped)
      {
        if (z == 0)
        {
          continue;
        }

        // if already single charged or no decharging selected keep peak as it is
        if (!make_single_charged)
        {
          in.push_back(old_spectrum[i]);
        }
        else
        {
          RichPeak1D p = old_spectrum[i];
          p.setMZ(p.getMZ() * z - (z - 1) * Constants::PROTON_MASS_U);
          in.push_back(p);
        }
      }
      else
      {
        // keep all unassigned peaks
        if (features[i] < 0)
        {
          in.push_back(old_spectrum[i]);
          continue;
        }

        // convert mono-isotopic peak with charge assigned by deisotoping
        if (z != 0)
        {
          if (!make_single_charged)
          {
            in.push_back(old_spectrum[i]);
          }
          else
          {
            RichPeak1D p = old_spectrum[i];
            p.setMZ(p.getMZ() * z - (z - 1) * Constants::PROTON_MASS_U);
            in.push_back(p);
          }
        }
      }
    }

    in.sortByPosition();
  }