Пример #1
0
static BYTE getspbVRch(void) {
	BYTE	ret = 0;

	if (getControlValue('spvl', 0)) {
		ret++;
	}
	if (getControlValue('spvr', 0)) {
		ret += 2;
	}
	return(ret);
}
Пример #2
0
 Knob::Knob(const parameters::ParameterInfo& inParamInfo,
            juce::AudioProcessor* inProcessor)
     : Control(inParamInfo, inProcessor)
     , juce::Slider(juce::Slider::RotaryHorizontalVerticalDrag, juce::Slider::TextBoxBelow)
 {
     setRange(0., 1., .005);
     setValue(double(getControlValue()), juce::dontSendNotification);
     setDoubleClickReturnValue(true, getNormalizedDefaultValue());
 }
Пример #3
0
 double Knob::getValueFromText(const juce::String& inText)
 {
     float val = 0.f;
     if (getControlValueFromText(inText, val))
     {
         return double(val);
     }
     return double(getControlValue());
 }
Пример #4
0
void control( void )
{
    motorval val;

    val = getControlValue();

    Motor_rotate( &(robot.leftMotor)  , val.leftmotor);
    Motor_rotate( &(robot.rightMotor) , val.rightmotor);
    Motor_rotate( &(robot.tailMotor)  , val.tailmotor);
}
Пример #5
0
 Combo::Combo(const parameters::ParameterInfo& inParamInfo,
              juce::AudioProcessor* inProcessor)
     : Control(inParamInfo, inProcessor)
 {
     const int numValues = static_cast<int>(getPlainValue(1.f)) + 1;
     for (int i = 0; i < numValues; ++i)
     {
         addItem(getControlValueText(getNormalizedValue(float(i))), i + 1);
     }
     setJustificationType(juce::Justification::centred);
     setSelectedItemIndex(static_cast<int>(getPlainValue(getControlValue())),
                          juce::dontSendNotification);
     addListener(this);
 }
Пример #6
0
static BYTE getsnd86int(void) {
	switch (getControlValue('86in', 0))
    {
		case 1:
			return(0x00);

		case 2:
			return(0x04);

		case 4:
			return(0x08);
	}
	return(0x0c);
}
Пример #7
0
//-----change
static BYTE getsnd26int(OSType board) {
	switch (getControlValue(board, 0))
    {
		case 1:
			return(0x00);

		case 2:
			return(0x80);

		case 4:
			return(0x40);
	}
	return(0xc0);
}
int main (int argc, char *argv[]) {
	//HARDY WEINBERG EQUILIBRIUM QUALITY CONTROL
	//Get the data	
	Datacube datacube;
	datacube.loadData(argv[1]);
	datacube.setVariablesMeaning(argv[6]);
	
	int countsCol = datacube.values.at(0).size() - 1;//The column with the counts

	//Set the threshold
	float threshold;
	threshold = atof(argv[2]);

	//Set the target variables index if the test will only be applied on controls
	bool onlyOnControls = false;
	int targetVarIndex = countsCol - 1;
	int CONTROL_VAL;
	if(argv[3][0] == '1')
	{
		onlyOnControls = true;
		CONTROL_VAL = getControlValue(&datacube,targetVarIndex);
	}
	
	
	bool keep[countsCol];
	for(int i=0; i<datacube.values.at(0).size(); ++i)
	{
        //initialize the values of the vectors
		keep[i] = true;
	}
	
    //initialize the counters
	int minorHom=0, majorHom=0, h1count=0, h2count=0, heterozygous=0;
	
	//Check which variables pass the HWE QC
	double pValue;
	for(int column=0;column<countsCol;column++) 
	{
        //Only if the variable is a SNP
		if(datacube.getVariableType(column).compare("SNP")==0)
		{
			h1count = 0;h2count = 0; heterozygous = 0;
			for(int row=0;row<datacube.values.size();row++)
			{	
				//chech if only controls should be used 
				if(!onlyOnControls || (onlyOnControls && datacube.values.at(row).at(targetVarIndex) == CONTROL_VAL))
				{
					switch(datacube.values.at(row).at(column))
					{
                        //count the minor alleles
						case HOMOZYGOUS_1:
							h1count += datacube.values.at(row).at(countsCol);
							break;
						//count the heterozygous alleles
						case HETEROZYGOUS:
							heterozygous += datacube.values.at(row).at(countsCol);
							break;	
						//count the major alleles
						case HOMOZYGOUS_2:
							h2count += datacube.values.at(row).at(countsCol);
					}
				}
			}
				
			//Set the minor and major alleles
			if(h1count<h2count)
			{
				minorHom = h1count;
				majorHom = h2count;
			}
			else
			{
				minorHom = h2count;
				majorHom = h1count;				
			}
				
			//If no alleles were counted (e.g. all missing, no controls)
			if(h1count == 0 && h2count==0 && heterozygous==0)
			{
				keep[column] = false;
			}
			else
			{	
				//calculate the HWE pValue
				pValue = SNPHWE(heterozygous,minorHom,majorHom);
				//Check if the SNP will be kept
				if(pValue < threshold )
					keep[column] = false;
			}
		}
	}

	//Remove the variables that did not pass the HWE QC
    datacube.removeVariables(keep);
    //output the data cube
	datacube.writeToFile(argv[4]);		
	
	
	//Output the XML contents describing the algorithm
	ofstream outpXML;
	outpXML.open(argv[5]);
	
	outpXML << "<log>" << endl;
	outpXML << "<QualityControl algorithm_name=\"Hardy Weinberg Equilibrium Test\" algorithmParamsSetting=\"threshold=" << argv[2];
	outpXML << " only_on_controls=" << argv[3] << "\"/>" << endl;
	outpXML << "</log>";	
	
	outpXML.close();
	
}
Пример #9
0
static pascal OSStatus cfWinproc(EventHandlerCallRef myHandler, EventRef event, void* userData) {
    OSStatus	err = eventNotHandledErr;
    HICommand	cmd;
    BYTE 		defaultmix[5] = {64, 64, 64, 64, 64};
    BYTE		b;

    if (GetEventClass(event)==kEventClassCommand && GetEventKind(event)==kEventCommandProcess ) {
        GetEventParameter(event, kEventParamDirectObject, typeHICommand, NULL, sizeof(HICommand), NULL, &cmd);
        switch (cmd.commandID)
        {
            case 'vDEF':
                initMixer(defaultmix);
                break;
                
            case '26io':
                setjmper(&snd26, (getMenuValue == 1)?0x10:0x00, 0x10);
                break;

            case '26in':
                setjmper(&snd26, getsnd26int(cmd.commandID), 0xc0);
                break;

            case '26rm':
                setjmper(&snd26, getMenuValue, 0x07);
                break;

            case '26DF':
                snd26 = 0xd1;
                set26s(snd26, '26io', '26in', '26rm');
                break;
                
            case '86io':
                setjmper(&snd86, (getMenuValue == 0)?0x01:0x00, 0x01);
                break;

            case '86it':
                setjmper(&snd86, (getControlValue(cmd.commandID, 0))?0x10:0x00, 0x10);
                break;

            case '86in':
                setjmper(&snd86, getsnd86int(), 0x0c);
                break;

            case '86id':
                setjmper(&snd86, (~getMenuValue & 7) << 5, 0xe0);
                break;

            case '86rm':
                setjmper(&snd86, (getControlValue(cmd.commandID, 0))?0x02:0x00, 0x02);
                break;

            case '86DF':
                snd86 = 0x7f;
                set86s();
                break;

            case 'spio':
                setjmper(&spb, (getMenuValue == 1)?0x10:0x00, 0x10);
                break;
                
            case 'spin':
                setjmper(&spb, getsnd26int(cmd.commandID), 0xc0);
                break;

            case 'sprm':
                setjmper(&spb, getMenuValue, 0x07);
                break;

            case 'spvl':
            case 'spvr':
                b = getspbVRch();
                if ((spbvrc ^ b) & 3) {
                    spbvrc = b;
                }
                break;

            case 'spDF':
                spb = 0xd1;
                spbvrc = 0;
                setSPB();
                break;

            case kHICommandOK:
                changeSoundOpt();
                endLoop(soundWin);
                err=noErr;
                break;
                
            case kHICommandCancel:
                revertTemporal();
                endLoop(soundWin);
                err=noErr;
                break;
                
            case JOYPAD_UP:
            case JOYPAD_DOWN:
            case JOYPAD_LEFT:
            case JOYPAD_RIGHT:
            case JOYPAD_ABUTTON:
            case JOYPAD_BBUTTON:
                err=setupJoyConfig(cmd.commandID);
                break;
                
            default:
                break;
        }
    }

	(void)myHandler;
	(void)userData;
    return err;
}
Пример #10
0
static void changeSoundOpt(void) {
    SINT32	val;
	UInt8	update;
	int		renewal;
    short	i,j;
    
    renewal = 0;
    for (j=0;j<5;j++) {
        val = getControlValue('vMix', j);
        if (val != *cfg[j]) {
            *cfg[j] = val;
            renewal = 1;
        }
    }
    if (renewal) {
        sysmng_update(SYS_UPDATECFG);
    }
    opngen_setvol(np2cfg.vol_fm);
    psggen_setvol(np2cfg.vol_ssg);
    rhythm_setvol(np2cfg.vol_rhythm);
    rhythm_update(&g_rhythm);
    adpcm_setvol(np2cfg.vol_adpcm);
    adpcm_update(&g_adpcm);
    pcm86gen_setvol(np2cfg.vol_pcm);
    pcm86gen_update();

    renewal = 0;
    for (i=0;i<6;i++) {
        val = getControlValue('vMix',i+10);
        if (val != np2cfg.vol14[i]) {
            np2cfg.vol14[i] = val;
            renewal = 1;
        }
    }
    if (renewal) {
        sysmng_update(SYS_UPDATECFG);
        tms3631_setvol(np2cfg.vol14);
    }

    if (np2cfg.snd26opt != snd26) {
        np2cfg.snd26opt = snd26;
        sysmng_update(SYS_UPDATECFG);
    }
    if (np2cfg.snd86opt != snd86) {
        np2cfg.snd86opt = snd86;
        sysmng_update(SYS_UPDATECFG);
    }

    update = 0;
    if (np2cfg.spbopt != spb) {
        np2cfg.spbopt = spb;
        update |= SYS_UPDATECFG;
    }
    if (np2cfg.spb_vrc != spbvrc) {
        np2cfg.spb_vrc = spbvrc;
        update |= SYS_UPDATECFG;
    }
    val = getControlValue('splv', 0);
    if (np2cfg.spb_vrl != val) {
        np2cfg.spb_vrl = val;
        update |= SYS_UPDATECFG;
    }
    opngen_setVR(np2cfg.spb_vrc, np2cfg.spb_vrl);
    val = getControlValue('sprv', 0);
    if (np2cfg.spb_x != val) {
        np2cfg.spb_x = val;
        update |= SYS_UPDATECFG;
    }
    sysmng_update(update);
    changeJoyPadSetup();                
}