Example #1
0
static IDnum expectedNumberOfConnections(IDnum IDA, Connection * connect,
					 IDnum ** counts, Category cat)
{
	Node *A = getNodeInGraph(graph, IDA);
	Node *B = connect->destination;
	IDnum IDB = getNodeID(B);
	double left, middle, right;
	Coordinate longLength, shortLength, D;
	double M, N, O, P;
	Coordinate mu = getInsertLength(graph, cat);
	double sigma = sqrt(getInsertLength_var(graph, cat));
	double result;
	double densityA, densityB, minDensity;

	if (mu <= 0)
		return 0;

	if (getNodeLength(A) == 0 || getNodeLength(B) == 0)
		return 0;

	if (getNodeLength(A) < getNodeLength(B)) {
		longLength = getNodeLength(B);
		shortLength = getNodeLength(A);
	} else {
		longLength = getNodeLength(A);
		shortLength = getNodeLength(B);
	}

	densityA = counts[cat][IDA + nodeCount(graph)] / (double) getNodeLength(A);
	densityB = counts[cat][IDB + nodeCount(graph)] / (double) getNodeLength(B);
	minDensity = densityA > densityB ? densityB : densityA;

	D = getConnectionDistance(connect) - (longLength +
					      shortLength) / 2;

	M = (D - mu) / sigma;
	N = (D + shortLength - mu) / sigma;
	O = (D + longLength - mu) / sigma;
	P = (D + shortLength + longLength - mu) / sigma;

	left = ((norm(M) - norm(N)) - M * normInt(M, N)) * sigma;
	middle = shortLength * normInt(N, O);
	right = ((norm(O) - norm(P)) - P * normInt(O, P)) * (-sigma);

	result = (minDensity * (left + middle + right));

	if (result > 0)
		return (IDnum) result;
	else
		return 0;
}
Example #2
0
static IDnum expectedNumberOfConnections(IDnum IDA, Connection * connect,
					 IDnum ** counts, Category cat)
{
	Node *A = getNodeInGraph(graph, IDA);
	Node *B = connect->destination;
	double left, middle, right;
	Coordinate longLength, shortLength, D;
	IDnum longCount;
	double M, N, O, P;
	Coordinate mu = getInsertLength(graph, cat);
	double sigma = sqrt(getInsertLength_var(graph, cat));
	double result;

	if (mu <= 0)
		return 0;

	if (getNodeLength(A) < getNodeLength(B)) {
		longLength = getNodeLength(B);
		shortLength = getNodeLength(A);
		longCount = counts[cat][getNodeID(B) + nodeCount(graph)];
	} else {
		longLength = getNodeLength(A);
		shortLength = getNodeLength(B);
		longCount = counts[cat][IDA + nodeCount(graph)];
	}

	D = connect->distance - (longLength + shortLength) / 2;

	M = (D - mu) / sigma;
	N = (D + shortLength - mu) / sigma;
	O = (D + longLength - mu) / sigma;
	P = (D + shortLength + longLength - mu) / sigma;

	left = ((norm(M) - norm(N)) - M * normInt(M, N)) * sigma;
	middle = shortLength * normInt(N, O);
	right = ((norm(O) - norm(P)) - P * normInt(O, P)) * (-sigma);

	result = (longCount * (left + middle + right)) / longLength;

	if (result > 0)
		return (IDnum) result;
	else
		return 0;
}
Example #3
0
void data::preprocessPeaks()
{
	// trie les pics par masse (ce qu'ils sont sense deja etre, mais juste au cas ou)
	qsort(peakList, peakNb, sizeof(PEAKS), compar_PEAK_MASSES);
	
	// je commence par marquer la masse parente et ses isotopes
	markParentMass();
	
	// trie les pics par intensite pour la normalisation et l'enlevement
	// des pics de basse intensite
	qsort(peakList, peakNb, sizeof(PEAKS), compar_PEAKS);
	normInt();
	
	// vire les pics qui ont une intensite en dessous du seuil de PEAK_INT_SEUIL
	for (int i = 0; i < peakNb; i++) {
		if (peakList[i].intensity < runManParam->PEAK_INT_SEUIL) {
			peakNb = i;
			break;
		}
	}
	
	// attribution des charges a considerer pour chaque pic
	for (int i = 0; i < peakNb; i++) {
		if ((peakList[i].mass - 4 > (parentMassM+2)/2) && (peakList[i].mass - 4 < parentMassM)) {
			// le +4, c'est pour que tous les isotopes d'un pic parent soient classes comme
			// le pic parent, meme s'ils sont a +1, +2 ou +3...
			peakList[i].CHARGE1 = true;
		}
		if ((peakList[i].mass - 4 > (parentMassM+3)/3) && (peakList[i].mass - 4 < (parentMassM+2)/2)) {
			peakList[i].CHARGE1 = true; 
			peakList[i].CHARGE2 = true;
		}
		if (peakList[i].mass - 4 < (parentMassM+3)/3) {
			peakList[i].CHARGE1 = true; 
			peakList[i].CHARGE2 = true; 
			peakList[i].CHARGE3 = true;
		}
	}

	// trie les pics par masse pour le controle des isotopes
	qsort(peakList, peakNb, sizeof(PEAKS), compar_PEAK_MASSES);
	
	// vire tous les pics isopopiques qui ne sont pas le premier isotope
	for (int i = 0; i < peakNb; i++) {
		for (int j = i+1; j < peakNb; j++) {
			// recherche d'isotopes a +0.333, +0.5, +1 selon les charges a considerer pour le pic courant
			// qui dependent de la region du spectre ou se trouve le pic
			
			// +0.333
			if (peakList[i].CHARGE3 == true) {
				if ((fabs((peakList[j].mass - peakList[i].mass) - 0.333333333333333333) < runManParam->FRAGMENT_ERROR1)
					&& (peakList[j].intensity < peakList[i].intensity)) {  
					// je prends l'erreur 1 car je compare des isotopes
					// exiger que l'intensite soit plus petite fait qu'on va manquer d'oter certains isotopes (hautes masses)
					// mais je prefere en garder trop que pas assez
					peakList[j].used = true;
				}
			}
			
			// +0.5
			if (peakList[i].CHARGE2 == true) {
				if ((fabs((peakList[j].mass - peakList[i].mass) - 0.5) < runManParam->FRAGMENT_ERROR1)
					&& (peakList[j].intensity < peakList[i].intensity)) {
					peakList[j].used = true;
				}
			}
			
			// +1
			if (peakList[i].CHARGE1 == true) {
				if ((fabs((peakList[j].mass - peakList[i].mass) - 1) < runManParam->FRAGMENT_ERROR1)
					&& (peakList[j].intensity < peakList[i].intensity)) {
					peakList[j].used = true;
				}
			}
			
			if (peakList[j].mass - peakList[i].mass > 4) {
				break;
			}
		}
	}
  
	// vire les pics doubles (je garde a chaque fois le pic de plus grande intensite)
	for (int i = 0; i < peakNb; i++) {
		for (int j = i+1; j < peakNb; j++) {
			if (fabs(peakList[j].mass - peakList[i].mass) < runManParam->FRAGMENT_ERROR1) {
				// repere le pic de + grande intensite
				if (peakList[i].intensity > peakList[j].intensity) {
					peakList[j].used = true;
				}
				else {
					peakList[i].used = true;
				}
			}
		}
	}
}