1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156
|
/*
* Copyright (c) Medical Research Council 2001. All rights reserved.
*
* Permission to use, copy, modify and distribute this software and its
* documentation for any purpose is hereby granted without fee, provided that
* this copyright and notice appears in all copies.
*
* This file was written as part of the Staden Package at the MRC Laboratory
* of Molecular Biology, Hills Road, Cambridge, CB2 2QH, United Kingdom.
*
* MRC disclaims all warranties with regard to this software.
*
*/
#include <climits> // For INT_MIN, INT_MAX
#include <peakcall.hpp>
//------
// Init
//------
void PeakCall::Init()
{
for( int n=0; n<4; n++ )
{
Data.Width[n] = -1;
Data.Position[n] = -1;
Data.Amplitude[n] = -1;
}
Data.BaseNumber = -1;
Data.BasePosition = -1;
}
//-------------
// Constructor
//-------------
PeakCall::PeakCall( int a, int c, int g, int t, int bnum, int bpos )
{
Data.Amplitude[0] = a;
Data.Amplitude[1] = c;
Data.Amplitude[2] = g;
Data.Amplitude[3] = t;
Data.BaseNumber = bnum;
Data.BasePosition = bpos;
}
//---------
// IsValid
//---------
bool PeakCall::IsValid() const
{
const int* Amp = Data.Amplitude;
if( (Amp[0]!=-1) || (Amp[1]!=-1) || (Amp[2]!=-1) || (Amp[3]!=-1) )
return true;
return false;
}
//----------
// MaxWidth
//----------
int PeakCall::MaxWidthAsIndex() const
{
int n = -1;
int nMax = INT_MIN;
if( (Data.Position[0]!=-1) && (Data.Width[0]>nMax) )
{
nMax = Data.Width[0];
n = 0;
}
if( (Data.Position[1]!=-1) && (Data.Width[1]>nMax) )
{
nMax = Data.Width[1];
n = 1;
}
if( (Data.Position[2]!=-1) && (Data.Width[2]>nMax) )
{
nMax = Data.Width[2];
n = 2;
}
if( (Data.Position[3]!=-1) && (Data.Width[3]>nMax) )
n = 3;
return n;
}
//--------------
// MaxAmplitude
//--------------
int PeakCall::MaxAmplitudeAsIndex() const
{
int n = -1;
int nMax = INT_MIN;
if( (Data.Position[0]!=-1) && (Data.Amplitude[0]>nMax) )
{
nMax = Data.Amplitude[0];
n = 0;
}
if( (Data.Position[1]!=-1) && (Data.Amplitude[1]>nMax) )
{
nMax = Data.Amplitude[1];
n = 1;
}
if( (Data.Position[2]!=-1) && (Data.Amplitude[2]>nMax) )
{
nMax = Data.Amplitude[2];
n = 2;
}
if( (Data.Position[3]!=-1) && (Data.Amplitude[3]>nMax) )
n = 3;
return n;
}
//--------------
// MinAmplitude
//--------------
int PeakCall::MinAmplitudeAsIndex() const
{
int n = -1;
int nMin = INT_MAX;
if( (Data.Position[0]!=-1) && (Data.Amplitude[0]<nMin) )
{
nMin = Data.Amplitude[0];
n = 0;
}
if( (Data.Position[1]!=-1) && (Data.Amplitude[1]<nMin) )
{
nMin = Data.Amplitude[1];
n = 1;
}
if( (Data.Position[2]!=-1) && (Data.Amplitude[2]<nMin) )
{
nMin = Data.Amplitude[2];
n = 2;
}
if( (Data.Position[3]!=-1) && (Data.Amplitude[3]<nMin) )
n = 3;
return n;
}
|