23 using namespace kome::objects;
28 #define new new( _NORMAL_BLOCK, __FILE__, __LINE__ )
29 #define malloc( s ) _malloc_dbg( s, _NORMAL_BLOCK, __FILE__, __LINE__ )
34 #define DEFAULT_RESOLUTION 0.3
45 m_name =
NVL( name,
"" );
61 m_polarity = POLARITY_UNKNOWN;
62 m_centroidMode =
false;
75 m_props.
setValue(
"Name", m_name.c_str() );
84 m_autoZeroPoints =
true;
87 m_strSpotId = FMT(
"" );
114 m_name = std::string(
NVL( name,
"" ) ) ;
115 if( m_title.empty() ) {
119 m_props.
setValue(
"Name", m_name.c_str() );
125 return m_name.c_str();
148 if( startRt >= 0.0 && endRt >= 0.0 ) {
186 double rt = ( m_rt.start + m_rt.end ) / 2.0;
205 m_props.
setValue(
"Spectrum Type", m_specType.c_str() );
211 return m_specType.c_str();
218 m_props.
setValue(
"Title", m_title.c_str() );
225 if( m_title.empty() ) {
226 std::string name = m_name;
231 if( !values.empty() ) {
232 values.append(
"," );
234 values.append( FMT(
"scanNum=%d", scanNum ) );
239 if( !values.empty() ) {
240 values.append(
"," );
242 values.append( FMT(
"rt=%.2f", rt ) );
247 if( !values.empty() ) {
248 values.append(
"," );
250 values.append( FMT(
"precursor=%.2f", prec ) );
253 if( values.empty() ) {
256 else if( name.empty() ) {
260 m_title = FMT(
"%s: %s", name.c_str(), values.c_str() );
264 return m_title.c_str();
269 m_icon = std::string(
NVL( icon,
"" ) );
275 return m_icon.c_str();
304 operation->
update( *xyData, *xyData, *
this );
312 if( xyData ==
NULL ) {
321 if( minX < 0.0 && maxX < 0.0 ) {
330 if( !m_tic || !m_bpi || m_bpm < 0.0 ) {
335 for(
unsigned int i = 0; i < length; i++ ) {
336 double x = dps.
getX( i );
337 double y = dps.
getY( i );
368 if( zero && m_autoZeroPoints ) {
379 const double space = DEFAULT_RESOLUTION;
382 double prevX = dps.
getX( 0 );
383 if( prevX > 0.0 && prevX > minX ) {
384 prevX = prevX - space / 3.0;
396 for(
unsigned int i = 0; i < dps.
getLength(); i++ ) {
397 const double x = dps.
getX( i );
398 const double y = dps.
getY( i );
400 const double d = x - prevX;
403 const double startX = prevX + space / 3.0;
404 const double endX = x - space / 3.0;
408 const int num = (int)( ( endX - startX ) / space );
410 for(
int j = 0; j < num; j++ ) {
411 double midX = startX + (double)j * ( endX - startX ) / (double)( num + 2 );
412 if( midX > startX && midX < endX ) {
426 if( maxX < 0.0 || prevX < maxX ) {
427 prevX = prevX + space / 3.0;
428 if( maxX >= 0.0 && prevX > maxX ) {
436 for(
unsigned int i = 0; i < dps.
getLength(); i++ ) {
465 double minX = double();
466 double maxX = double();
482 m_props.
setValue(
"High Mass",
"" );
493 double minX = double();
494 double maxX = double();
506 if( intensity > 0.0 ) {
519 if( minX < 0.0 && maxX < 0.0 ) {
529 if( minX < 0.0 && maxX < 0.0 ) {
538 if( intensity > 0.0 ) {
551 if( minX < 0.0 && maxX < 0.0 ) {
561 if( minX < 0.0 && maxX < 0.0 ) {
596 for(
int i = 1; i < m_msStage; i++ ) {
597 std::string key = FMT(
"Precursor%d (Mass)", i );
598 m_props.
setValue( key.c_str(),
"" );
600 key = FMT(
"Precursor%d (Intensity)", i );
601 m_props.
setValue( key.c_str(),
"" );
610 double intensity = -1.0;
612 for(
unsigned int i = 0; i < m_precursor.size() && idx < 0; i++ ) {
613 if( m_precursor[ i ].stage < 0 ) {
615 prec = m_precursor[ i ].precursor;
616 intensity = m_precursor[ i ].intensity;
621 m_precursor.erase( m_precursor.begin() + idx );
627 if( intensity >= 0.0 ) {
643 std::string key = FMT(
"Precursor%d (Mass)", stage );
646 key = FMT(
"Precursor%d (Intensity)", stage );
647 if( !m_props.
hasKey( key.c_str() ) ) {
648 m_props.
setValue( key.c_str(),
"" );
652 if( m_msStage > 1 && stage == m_msStage - 1 ) {
657 for(
unsigned int i = 0; i < m_precursor.size(); i++ ) {
658 if( m_precursor[ i ].stage == stage ) {
659 m_precursor[ i ].precursor = precursor;
665 m_precursor.resize( m_precursor.size() + 1 );
666 m_precursor.back().stage = stage;
667 m_precursor.back().intensity = -1.0;
668 m_precursor.back().precursor = precursor;
674 if( m_msStage > 1 ) {
685 for(
unsigned int i = 0; i < m_precursor.size(); i++ ) {
686 if( m_precursor[ i ].stage == stage ) {
687 return m_precursor[ i ].precursor;
697 int stage = ( m_msStage > 1 ? ( m_msStage - 1 ) : -1 );
704 if( intensity < 0.0 ) {
710 std::string key = FMT(
"Precursor%d (Mass)", stage );
711 if( !m_props.
hasKey( key.c_str() ) ) {
712 m_props.
setValue( key.c_str(),
"" );
715 key = FMT(
"Precursor%d (Intensity)", stage );
719 if( m_msStage > 1 && stage == m_msStage - 1 ) {
724 for(
unsigned int i = 0; i < m_precursor.size(); i++ ) {
725 if( m_precursor[ i ].stage == stage ) {
726 m_precursor[ i ].intensity = intensity;
732 m_precursor.resize( m_precursor.size() + 1 );
733 m_precursor.back().stage = stage;
734 m_precursor.back().precursor = -1.0;
735 m_precursor.back().intensity = intensity;
740 if( m_msStage > 1 ) {
752 double intensity = -1.0;
753 for(
unsigned int i = 0; i < m_precursor.size(); i++ ) {
754 if( m_precursor[ i ].stage == stage ) {
755 intensity = m_precursor[ i ].intensity;
758 if( intensity >= 0.0 ) {
765 if( precursor < 0.0 ) {
769 std::set< Spectrum* > parentSet;
770 parentSet.insert(
this );
771 parentSet.insert( parent );
774 if( parentSet.find( parent ) == parentSet.end() ) {
775 parentSet.insert( parent );
782 if( parent !=
NULL ) {
785 parent->
getXYData( &dps, precursor - 0.5, precursor + 0.5,
false );
787 for(
unsigned int i = 0; i < dps.
getLength(); i++ ) {
788 intensity = std::max( intensity, dps.
getY( i ) );
799 int stage = ( m_msStage > 1 ? ( m_msStage - 1 ) : -1 );
811 m_props.
setValue(
"Precursor Charge",
"" );
823 m_parentSpec = parent;
826 std::set< Spectrum* > parentSet;
827 parentSet.insert(
this );
828 parentSet.insert( parent );
834 if( precursor < 0.0 ) {
840 if( parentSet.find( p ) == parentSet.end() ) {
841 parentSet.insert( p );
863 if( m_children.size() == 0 ) {
870 m_children.push_back( spec );
877 for(
unsigned int i = 0; i < m_children.size(); i++ ) {
878 children.push_back( m_children[ i ] );
884 m_chrom = chromatogram;
908 m_props.
setValue(
"Scan Number",
"" );
923 ( polarity == POLARITY_POSITIVE ?
"+" : (polarity == POLARITY_NEGATIVE ?
"-" :
"" ) )
926 m_polarity = polarity;
937 m_centroidMode = centroidMode;
942 return m_centroidMode;
948 m_resolution = resolution;
958 m_props.
setValue(
"Collision Energy",
NVL( collisionEnergy,
"" ) );
959 m_collisionEnergy =
NVL( collisionEnergy,
"" );
964 return m_collisionEnergy.c_str();
984 m_autoZeroPoints = autoZero;
989 return m_autoZeroPoints;
1022 if( peaks !=
NULL ) {
1025 std::string chargeStr;
1029 if( !chargeStr.empty() ) {
1030 chargeStr.append(
", " );
1033 chargeStr.append( FMT(
"%d", charge ) );
1037 if( precursor < 0.0 ) {
1038 properties.
setValue(
"Calculated Precursor",
"" );
1043 properties.
setValue(
"Calculated Precursor Charge", chargeStr.c_str() );
1049 while( group !=
NULL ) {
1071 while( group !=
NULL ) {
1085 const char* keys[] = {
1097 "Precursor Intensity",
1109 const unsigned int num =
sizeof( keys ) /
sizeof(
const char* );
1111 for(
unsigned int i = 0; i < num; i++ ) {
1146 m_strSpotId = std::string(
NVL( pcSpotId,
"" ) );
1147 m_props.
setValue(
"Spot ID", m_strSpotId.c_str( ) );
1156 return m_strSpotId.c_str( );
1168 void Spectrum::resetRequestLoadData(
void )
double getPrecursorIntensity()
gets the precursor intensity of the precursor ion spectrum.
double getStartRt()
gets the start of retention time
int issueSpecId()
to issue the spectrum id
abstraction class of two dimention coordinate data
unsigned int getNumberOfCharges()
gets the number of charges
void setTotalIntensity(const double intensity)
sets total intensity of spectrum
void setMaxIntensity(const double intensity)
sets max intensity of spectrum
kome::core::Properties & getUserProperties()
gets user properties
Spectrum(Sample *sample, const char *name)
constructor
void setCollisionEnergy(const char *collisionEnergy)
sets the collision energy
group of spectrum management class
virtual bool onIsFirstAccess(void)
This method is called by isFirstAccess method. (abstract method)
Sample * getSample()
gets the sample that has this spectrum
bool firstAccessProcess(void)
method for processing when accessing the first item of this class
data points data of profile management class
interfaces of PointsManager class
double getPrecursor()
gets precursor
double getPrecursor(const int stage)
gets precursor
unsigned int getNumberOfOperations(Spectrum *spec)
gets the number of operations of specified spectrum
void setAutoZeroPoints(const bool autoZero)
sets auto zero points flag value
void setBoolValue(const char *key, bool value)
sets parameter value
double getRt()
gets retention time
bool isFirstAccess(void)
check the flag of first access
interfaces of PeaksManager class
double getX(const unsigned int index)
gets x coordinate
int getId()
gets spectrum id
Peaks * getPeaks(Spectrum *spec)
gets peaks of specified spectrum
void setMinX(const double minX)
sets min x
const char * getName()
gets spectrum name
bool isAutoZeroPoints()
gets auto zero points flag value
void setRt(const double rt)
sets retention time
const char * getCollisionEnergy()
gets the collision energy
sample information management class
void setPrecursor(const int stage, const double precursor)
sets precursor
void setPolarity(Polarity polarity)
sets polarity
void setPrecursorIntensity(const int stage, const double intensity)
sets precursor intensity
void setId(int id)
sets spectrum id
bool isVisible()
gets the visible flag value
DataGroupNode * getGroup(const unsigned int index)
gets spectrum group
keys and values management class
void setMaxX(const double maxX)
sets max x
const char * getIcon()
gets icon name
void setVisible(const bool visible)
sets the visible flag
void getChildSpectra(std::vector< Spectrum * > &children)
gets child spectra
void clearOperations(Spectrum *spec)
clears data operation of specified spectrum
void setSpotId(const char *pcSpotId)
set spot id param[in] pcSpotId SpotId information
virtual void onResetFirstAccess(void)
This method is called by resetFirstAccess method. (abstract method)
void setIcon(const char *icon)
sets icon name
void setValue(const char *key, const char *value)
sets parameter value
void setEndRt(const double rt)
sets end retention time
void setName(const char *name)
sets spectrum name
static PointsManager & getInstance()
get data points manager object (This is the only object.)
void setParentSpectrum(Spectrum *const parent)
sets parent spectrum
const char * getSpotId(void)
get spot id
static std::vector< std::string > m_commonProps
interfaces of SampleSet class
void setIntValue(const char *key, int value)
sets parameter value
data points management class
static void closeSpectrum(Spectrum *spec, const bool deleting)
This method is called when a spectrum is closed.
unsigned int getNumberOfSpectra()
gets the number of spectra
virtual double onGetMaxIntensity(const double minX, const double maxX)=0
This method is called by getMaxIntensity method. (abstract method)
short getCharge(const unsigned int index)
gets charge
void setCentroidMode(const bool centroidMode)
sets centroid mode or not
const char * getValue(const unsigned int index)
gets the parameter value
double getY(const unsigned int index)
gets y coordinate
std::string trimstring(const char *s)
remove white spaces from both ends of specified string
void update(kome::core::XYData &src, kome::core::XYData &dst, Chromatogram &chrom)
updates xy data
Spectrum * getOrgSpectrum()
gets original spectrum
interfaces of Spectrum class
int getPrecursorCharge()
gets the precursor charge
double getResolution()
gets resolution
kome::core::Properties & getProperties()
gets properties
static bool isCommonProperty(const char *key)
check whther the specified property key is common property or not
interfaces of XYDataOperation class
Spectrum * getSpectrum(const unsigned int index)
gets the number of spectra
interfaces of DataGroupNode class
double getMinX()
gets min x
int getMsStage()
gets ms stage
interfaces of Sample class
double getMaxX()
gets max x
unsigned int getNumberOfProperties()
gets the number of Properties
bool loadData(void)
load data
void setHasChromatogram(const bool chromatogram)
sets wheher this spectrum has chromatogram
int getScanNumber()
gets scan number
DataGroupNode * getParentGroup()
get parent spectrum group
void setRequestLoadData(void)
set the flag of request load data
virtual void onResetRequestLoadData(void)
This method is called by resetRequestLoadData method. (abstract method)
#define NVL(checkVal, replaceVal)
void setFirstAccess(void)
set the flag of first access
void deletePeaks(Spectrum *spec)
deletes peaks of specified spectrum
double getTotalIntensity(const double minX=-1.0, const double maxX=-1.0)
gets total intensity in specified range
virtual bool onIsRequestLoadData(void)
This method is called by isRequestLoadData method. (abstract method)
kome::core::XYData * getXYData()
gets xy data from data manager
const char * getKey(const unsigned int index)
gets the name of parameter
void resetFirstAccess(void)
reset the flag of first access
virtual bool onLoadData(void)
This method is called by loadData method. (abstract method)
void setMsStage(const int stage)
sets ms stage
double getPrecursor()
gets the precursor mass of precursor ion spectrum.
DataGroupNode * getGroup()
gets spectrum group
void setStartRt(const double rt)
sets start retention time
virtual double onGetTotalIntensity(const double minX, const double maxX)=0
This method is called by getTotalIntensity method. (abstract method)
kome::core::Properties & getProperties()
gets properties
kome::core::Properties & getUserProperties()
gets user properties
void setScanNumber(const int scan)
sets scan number
void setBasePeakMass(const double mass)
sets base peak mass
bool hasKey(const char *key)
judges whether this object has specified parameter key
const char * getTitle()
gets spectrum title
unsigned int getNumberOfGroups()
gets the number of spectrum groups
void setOrgSpectrum(Spectrum *spec)
sets original spectrum
kome::core::XYData * getXYData(Spectrum *spec)
gets xy data of specified spectrum
Spectrum * getParentSpectrum()
gets parent spectrum
spectrum information management class
void deleteXYData(Spectrum *spec)
deletes xy data of specified spectrum
virtual void onGetXYData(kome::core::XYData *const xyData, const double minX, const double maxX)=0
This method is called by getXYData method. (abstract method)
double getEndRt()
gets the end of retention time
void addPoint(const double x, const double y)
adds point
void setSpecType(const char *type)
sets spectrum type
const char * getSpecType()
gets spectrum type
XYDataOperation * getOperation(Spectrum *spec, const unsigned int index)
gets operation of specified spectrum
bool isRequestLoadData(void)
check the flag of request load data
virtual void onSetRequestLoadData(void)
This method is called by setRequestLoadData method. (abstract method)
void deleteXYData()
deletes xy data of data manager
void setGroup(DataGroupNode *group)
sets spectrum group
void setTitle(const char *title)
sets spectrum title
void setPrecursorCharge(const int charge)
sets the precursor charge
bool isCentroidMode()
judget wheter this spectrum is centroid mode
static PeaksManager & getInstance()
get peaks manager object (This is the only object.)
Polarity
polarity definition
void setResolution(const double resolution)
sets resolution
void setXRange(const double minX, const double maxX)
sets x range
double getMaxIntensity(const double minX=-1.0, const double maxX=-1.0)
gets max intensity in specified range
virtual void onGetXRange(double *minX, double *maxX)=0
This method is called by getMinX or getMaxX method. (abstract method)
Polarity getPolarity()
gets polarity
virtual ~Spectrum()
destructor
double getBasePeakMass()
gets base peak mass
virtual void onSetFirstAccess(void)
This method is called by setFirstAccess method. (abstract method)
unsigned int getLength()
gets the number of points @return the number of points
bool hasChromatogram()
judges whether this spectrum has chromatogram
void setDoubleValue(const char *key, double value)
sets parameter value