Esempio n. 1
0
void MI_CALL MSFT_Friends_AssociatorInstances(
    MSFT_Friends_Self* self,
    MI_Context* context,
    const MI_Char* nameSpace,
    const MI_Char* className,
    const MI_Instance* instanceName,
    const MI_Char* resultClass,
    const MI_Char* role,
    const MI_Char* resultRole,
    const MI_PropertySet* propertySet,
    MI_Boolean keysOnly,
    const MI_Filter* filter)
{
    if (MSFT_Person_IsA(instanceName))
    {
        if (_Match(role, MI_T("Left")) && 
            _Match(resultRole, MI_T("Right")))
        {
    if (((MSFT_Person*)instanceName)->Key.exists && ((MSFT_Person*)instanceName)->Key.value == 1)
    {
        MSFT_Person inst;
        MSFT_Person_Construct(&inst, context);
        MSFT_Person_Set_Key(&inst, 2);
        MSFT_Person_Set_First(&inst, MI_T("John"));
        MSFT_Person_Set_Last(&inst, MI_T("Adams"));
        MSFT_Person_Post(&inst, context);
        MSFT_Person_Destruct(&inst);
    }
}}

    if (MSFT_Person_IsA(instanceName))
    {
        if (_Match(role, MI_T("Right")) && 
            _Match(resultRole, MI_T("Left")))
        {
    if (((MSFT_Person*)instanceName)->Key.exists && ((MSFT_Person*)instanceName)->Key.value == 2)
    {
        MSFT_Person inst;
        MSFT_Person_Construct(&inst, context);
        MSFT_Person_Set_Key(&inst, 1);
        MSFT_Person_Set_First(&inst, MI_T("George"));
        MSFT_Person_Set_Last(&inst, MI_T("Washington"));
        MSFT_Person_Post(&inst, context);
        MSFT_Person_Destruct(&inst);
    }
}}
    MI_PostResult(context, MI_RESULT_OK);
}
Esempio n. 2
0
double CXLinkOpenScorer::Score()
{
	if(0 == m_pSpectrum->m_tPeaksNum)
	{
		return 0.0;
	}

	if(!m_bComputeMz)
	{
		_ComputeMZ();
		m_bComputeMz = true;
	}
	_Match();
	
	double F = 0.0;
	
	double K = 0.5; 

	int N,n,l,x,n0,x1;
	N = n = l = x = x1 = n0 = 0;

	N = int((m_pSpectrum->m_lfMH)/K);
	
	n = m_tIonNum;
	
	n0 = 10;
	if(n0 > n)
		n0 = n;
	
	int Pp = 0;
	int Bi = -1;
	double Pw = 0.0;
	vector<double> Puw ;
	Puw.clear();
	
	for(size_t i = 0; i < m_pSpectrum->m_tPeaksNum ; ++i )
	{
		if(int(m_pSpectrum->m_pPeaks[i].lfMz/K)>Bi)
		{
			l++;
			if(m_pnMatched[i]>=0)
			{
				x++;
				Pp += m_pPeakRank[i];
				
				double lfTmpTol ;
				lfTmpTol = ((_ShiftMass(m_pnMatched[i])+0.0)/MZMULTIPLIER - m_pSpectrum->m_pPeaks[i].lfMz);
				Puw.push_back(lfTmpTol);
				Pw += lfTmpTol;
				if(m_pPeakRank[i] < n0)
				{
					x1 ++;
				}
			}
			Bi = int(m_pSpectrum->m_pPeaks[i].lfMz/K);
		}
	}

	double Ji = 0.0;

	double Lpc = 0.0;
	double Lp = 0.0; 
	Lp = _CalProb(N, n, l, x);
	
	if(Lp == 0)
		return 0;
	
	Lpc = Lp;

	for(int i=x+1;i<=l;++i)
	{
		Lp = _CalProb(N,n,l,i);
		
		if(Lp != MINUS_INFINITE)
		{
			if(Lpc == MINUS_INFINITE)
				Lpc = Lp;
			else
				Lpc = log(exp(Lpc) + exp(Lp));
		}
	}

	double Lpr = 0.0;
	double Apr = (x == 0 || l < 10 ? 0.5 : (Pp/x)/(l+0.0));
	double Sig = ( x == 0 ? 0.1238 : 0.2887/sqrt(x) );
	
	int Lsnc = int(((Apr - 0.5)/Sig - (-5))/(0.1));
	if(Lsnc < 0)
		Lsnc = 0;
	else if(Lsnc > 100)
		Lsnc = 100;
	Lpr = m_lfLogStdNormCDF[Lsnc]; 

	double Lptl = 0.0;
	double R = GetMaxTagLength();

	int Pl = m_nPepLen - 1;

	if(Pl < 1)
		Pl = 1;
	if(Pl > 120)
		Pl = 120;
	Lptl = m_lfLogTagLenCDF[Pl-1][int(R/0.05)];

	double Lpl = 0.0;
	double Apt = (x == 0 ? 0 : (Pw/x));
	double Pts = 0.0;
	
	for(size_t i = 0;i < Puw.size() ; ++i)
	{
		Pts += (Puw[i] - Apt)*(Puw[i] - Apt);
	}
	if(x > 5)
	{
		Pts /= (x-1);
		Pts = sqrt(Pts);
		 
		int Lgc = int((Pts - 0.01)/0.01);
		if(Lgc < 0)
			Lgc = 0;
		else if(Lgc > 99)
			Lgc = 99;
		
		Lpl = m_lfLogGamaCDF[Lgc];
	}

	Ji = Lpc + Lpr + Lptl;
	
	F = - Ji;
	return F ; 
}