00001 
#ifndef _ISOCLUSTER_H_
00002 
#define _ISOCLUSTER_H_
00003 
00004 
00005 
00006 
00007 
00008 
00009 
#define CARBON_RICH     16.34
00010 
#define CARBON_POOR     34.34
00011 
00012 
#define MAX_NO_MS2_SCANS_PER_PEAK 50
00013 
00014 
extern int ISOCLUSTER_SCORE_RT_SD_WIDTH;
00015 
extern int ISOCLUSTER_SCORE_DELTA_MZ_SD_WIDTH;
00016 
extern int ISOCLUSTER_SCORE_RT_SD_DECIMAL_PLACES;
00017 
extern int ISOCLUSTER_SCORE_DELTA_MZ_SD_DECIMAL_PLACES;
00018 
00019 
struct ISOTOPIC_CLUSTER
00020 {
00021         
unsigned                        isSubset: 1;
00022         
00023         
unsigned int            isValid;
00024 
00025         
char*                           szSession;
00026         
int                                     peakgroup;
00027         
int                                     fpeak;
00028 
00029         
int                *index_array;
00030         
FPeak2iPointer     *pfpeaks;            
00031         
int                                     npeaks;
00032         
00033         
int                *zarray;
00034 
00035         
float                           dCharge;
00036 
00037         
float                           ab_avg;
00038         
float                           ab_sd;
00039 
00040         
float                           rt_avg;
00041         
float                           rt_sd;
00042 
00043         
float                           mz_avg;
00044         
float                           mz_sd;
00045 
00046         
float                           delta_mz_avg;
00047         
float                           delta_mz_sd;
00048 
00049         
int                                     ncupper;
00050         
int                                     nclower;
00051         
00052         
int                                     ncarbons;               
00053         
float                           dev;
00054         
int                                     mip;
00055 
00056 
00057         
Experiment*                     ms2exp;
00058         
int                                     ms2indices[MAX_NO_MS2_SCANS_PER_PEAK+1];        
00059 };
00060 
00061 
typedef struct ISOTOPIC_CLUSTER ISOTOPIC_CLUSTER;
00062 
typedef ISOTOPIC_CLUSTER IsotopicCluster;
00063 
typedef IsotopicCluster* IsotopicClusterPointer;
00064 
00065 
int                                             findSubsetClusters(
PeakGroup* PG);
00066 
int                                             isClusterSubsetOfSubset(ISOTOPIC_CLUSTER IC1, ISOTOPIC_CLUSTER IC2);
00067 
int                                             doesFPeak2iBelongToCluster(
FPeak2iPointer pfpeak, ISOTOPIC_CLUSTER IC);
00068 
00069 
00070 
00071 
#define IC_NPEAKS                       0x00000001
00072 
#define IC_ABUNDANCE            0x00000002
00073 
#define IC_CHARGE                       0x00000004
00074 
#define IC_PEAKGROUP            0x00000008
00075 
#define IC_CARBONS                      0x00000010
00076 
#define IC_FUNDAMENTAL          0x00000020
00077 
#define IC_PRIMARY_PEAK2I       0x00000040
00078 
#define IC_RT                           0x00000080
00079 
#define IC_MS2                          0x00000100
00080 
#define IC_NPEAKS_SD            0x00000200
00081 
#define IC_MZ                           0x00000400
00082 
00083 
enum {IC_TABLE, IC_WITH_HEADER};
00084 
00085 
int IsotopicCluster_cmpByCharge           (
const void *p1, 
const void *p2);
00086 
int IsotopicCluster_cmpByRT                       (
const void *p1, 
const void *p2);
00087 
int IsotopicCluster_cmpByMZ                       (
const void *p1, 
const void *p2); 
00088 
int     IsotopicCluster_cmpByAbundance    (
const void *p1, 
const void *p2);
00089 
int     IsotopicCluster_cmpByNPeaks       (
const void *p1, 
const void *p2);
00090 
int IsotopicCluster_cmpByPrimaryPeak2i(
const void *p1, 
const void *p2);
00091 
int IsotopicCluster_cmpByNPeaksSD         (
const void *p1, 
const void *p2);
00092 
00093 
void IsotopicClusterArray_sortByField(ISOTOPIC_CLUSTER *ICArray, 
int nic, 
int field);
00094 
00095 
int     cmpIsotopicClusterPointerByPrimaryPeak2i(
const void *p1, 
const void *p2);
00096 
00097 
void                                    sortIsotopicClusterPointerArrayByPrimaryPeak2i(IsotopicClusterPointer* ICPArray, 
int nicp);
00098 
void                                    IsotopicCluster_destroy(ISOTOPIC_CLUSTER *cluster);
00099 
void                                    IsotopicCluster_fprint     (FILE* fp, 
int index, ISOTOPIC_CLUSTER cluster,   
int format);
00100 
void                                    IsotopicCluster_init            (IsotopicCluster* isc, 
int npeaks);
00101 
void                                    IsotopicClusterArray_fprint(FILE* fp, ISOTOPIC_CLUSTER *clusters, 
int nclusters, 
int format);
00102 
void                                    IsotopicClusterArray_fprintWithIndex(FILE* fp, ISOTOPIC_CLUSTER *clusters, 
int nclusters, 
int start_index);
00103 IsotopicCluster*                IsotopicClusterArray_convertFromPeakGroupFile(PeakGroupFile* file, RestrictionStatistics* pRestr, 
int nRestr, 
int *nIsoclusters);
00104 
00105 
void                                    IsotopicClusterArray_destroy(ISOTOPIC_CLUSTER **cluster,  
int nclusters);
00106 IsotopicClusterPointer* createIsoclusterPointerArrayFromPeakGroupFile(PEAK_GROUP_FILE PGF, 
int* nicp);
00107 
00108 
int      IsotopicCluster_calcCarbonBounds(IsotopicCluster* cluster);
00109 
void IsotopicCluster_calcRT              (IsotopicCluster* IC);
00110 
void IsotopicCluster_calcDeltaMZ (IsotopicCluster* IC);
00111 
void IsotopicCluster_calcTotalAbu(IsotopicCluster* IC);
00112 
00113 
void IsotopicCluster_setPeakGroup(IsotopicCluster* IC, 
int peakgroup);
00114 
float guessAbundance(IsotopicCluster* ic, 
int index);
00115 
00116 
void IsotopicCluster_fixCharge(IsotopicCluster* IC, 
int charge);
00117 
void IsotopicCluster_createFromFPeak2i(IsotopicCluster* IC, 
FPeak2i* pFPeak);
00118 
00119 IsotopicCluster* IsotopicClusterArray_create(
int size);
00120 IsotopicCluster* IsotopicClusterArray_linkMS2Scans(IsotopicCluster* ica, 
int* nIsoclusters, 
Map2D* map);
00121 
void IsotopicCluster_rectangleQuantitation(IsotopicCluster* ic, 
Map2D* map, 
Rectangle4i rect);
00122 
00123 
void tprintIC(FILE* fp, IsotopicCluster* ic, 
int nsize);
00124 
00125 
int FPeak2iArray_getHighestScoringIsotopicCluster(
FPeak2i* pArray, 
int nArray, 
00126                                                                                                   IsotopicCluster* out);
00127 
00128 
#endif
00129 
00130