Ejemplo n.º 1
0
	void Evaluation::evaluation()
	{
		std::ifstream file(this->inputFile);
		if (file.is_open())
		{
			std::string line;
			float resp;
			int realClass, predictedClass;

			while (getline(file, line))
			{
				std::vector<std::string> split = splitString(line, ' ');
				predictedClass = atoi(split[1].c_str()) - 1; // Victor started them from 1
				realClass = atoi(split[2].c_str()) - 1; // Victor started them from 1
				resp = static_cast<float>(atof(split[3].c_str()));

				this->confusionMat[realClass][predictedClass]++;
				this->confusionMatScores[realClass][predictedClass].push_back(resp);
			}
			file.close();
			generateOutput();
		}
		else
			std::cerr << "Wrong input file." << std::endl;
	}
Ejemplo n.º 2
0
void MainWindow::generate_f(){
    QString polyString = polyField->text();
    QString startString = startValueField->text();

    polyString.remove(0,1);

    if(polyString.length() != startString.length()){
        resultDoc->setPlainText("Invalid Input");
        return;
    }

    if(!checkInput(polyString)){
        return;
    }
    if(!checkInput(startString)){
        return;
    }

    if((polyData = convertData(polyString)) == NULL){
        resultDoc->setPlainText("Invalid Input");
        return;
    }

    if((data = convertData(startString)) == NULL){
        resultDoc->setPlainText("Invalid Input");
        return;
    }

    std::reverse(polyData->begin(), polyData->end());

    generateOutput();
}
void JSCLanguageBase::add(const AdditionalClass& additionalClass) {
  std::vector<JSCPropertyPointer> properties;

  for (const auto& propertyPair : additionalClass.properties) {
    JSCPropertyType type = JSCProperty::propertyStringToType(std::get<0>(propertyPair));
    if (JSCProperty_Unknown == type) {
      SIAWarning("unsupported property type: %s", std::get<0>(propertyPair).c_str());
      continue;
    }

    JSCPropertyPointer property(new JSCProperty(type));
    property->setPath({std::get<1>(propertyPair)});
    property->setRequired(!std::get<2>(propertyPair));
    properties.push_back(property);
  }

  JSCObjectPointer newClass(new JSCObject(properties));
  newClass->setRootName(additionalClass.className);
  newClass->setPath({additionalClass.name});
  newClass->setCodeGenerate(true);
  newClass->setRequired(!additionalClass.optional);

  m_additionalClasses.push_back(newClass);

  for (const auto& out : generateOutput(newClass)) {
    m_outputs.push_back(out);
  }
}
Ejemplo n.º 4
0
/*! Default main. The idea of separating this from the rest of doxygen,
 *  is to make it possible to write your own main, with a different 
 *  generateOutput() function for instance.
 */
int main(int argc,char **argv)
{
  initDoxygen();
  readConfiguration(argc,argv);
  checkConfiguration();
  adjustConfiguration();
  parseInput();
  generateOutput();
  return 0;
}
void JSCLanguageBase::add(const JSCObjectPointer& object) {
  if (isIgnore(object)) {
    SIADebug("Ignore class with name: %s", object->rootName().c_str());
    return;
  }

  for (const auto& out : generateOutput(object)) {
    m_outputs.push_back(out);
  }
}
void JSCLanguageBase::add(const JSCEnumPointer& enumObj) {
  if (isIgnore(enumObj)) {
    SIADebug("Ignore enum with name: %s", enumObj->enumName().c_str());
    return;
  }

  for (const auto& out : generateOutput(enumObj)) {
    m_outputs.push_back(out);
  }
}
Ejemplo n.º 7
0
/**
 * @brief Main code generator dispatch.
 *
 * According to the type of the input signal, generateCode calls
 * the appropriate generator with appropriate arguments.
 *
 * @param	sig			The signal expression to compile.
 * @param	priority	The environment priority of the expression.
 * @return	<string>	The LaTeX code translation of the signal.
 */
string DocCompiler::generateCode (Tree sig, int priority)
{
	int 	i;
	double	r;
    Tree 	c, sel, x, y, z, u, label, ff, largs, type, name, file;
	
	if ( getUserData(sig) )							{ printGCCall(sig,"generateXtended");	return generateXtended	(sig, priority);		}
	else if ( isSigInt(sig, &i) ) 					{ printGCCall(sig,"generateNumber");	return generateNumber	(sig, docT(i));			}
	else if ( isSigReal(sig, &r) ) 					{ printGCCall(sig,"generateNumber");	return generateNumber	(sig, docT(r));			}
	else if ( isSigInput(sig, &i) ) 				{ printGCCall(sig,"generateInput");		return generateInput	(sig, docT(i+1)); 		}
	else if ( isSigOutput(sig, &i, x) ) 			{ printGCCall(sig,"generateOutput");	return generateOutput	(sig, docT(i+1), CS(x, priority));	}
	
	else if ( isSigFixDelay(sig, x, y) ) 			{ printGCCall(sig,"generateFixDelay");	return generateFixDelay	(sig, x, y, priority); 	}
	else if ( isSigPrefix(sig, x, y) ) 				{ printGCCall(sig,"generatePrefix");	return generatePrefix	(sig, x, y, priority); 	}
	else if ( isSigIota(sig, x) ) 					{ printGCCall(sig,"generateIota");		return generateIota 	(sig, x); 				}
	
	else if ( isSigBinOp(sig, &i, x, y) )			{ printGCCall(sig,"generateBinOp");		return generateBinOp	(sig, i, x, y, priority); 		}
	else if ( isSigFFun(sig, ff, largs) )			{ printGCCall(sig,"generateFFun");		return generateFFun 	(sig, ff, largs, priority); 	}
    else if ( isSigFConst(sig, type, name, file) )  { printGCCall(sig,"generateFConst");	return generateFConst	(sig, tree2str(file), tree2str(name)); }
    else if ( isSigFVar(sig, type, name, file) )    { printGCCall(sig,"generateFVar");		return generateFVar		(sig, tree2str(file), tree2str(name)); }
	
    // new special tables for documentation purposes

    else if ( isSigDocConstantTbl(sig, x, y) )      { printGCCall(sig,"generateDocConstantTbl");    return generateDocConstantTbl (sig, x, y);	}
    else if ( isSigDocWriteTbl(sig,x,y,z,u) )       { printGCCall(sig,"generateDocWriteTbl");       return generateDocWriteTbl (sig, x, y, z, u); }
    else if ( isSigDocAccessTbl(sig, x, y) )        { printGCCall(sig, "generateDocAccessTbl");     return generateDocAccessTbl(sig, x, y); }


	else if ( isSigSelect2(sig, sel, x, y) ) 		{ printGCCall(sig,"generateSelect2");	return generateSelect2 	(sig, sel, x, y, priority); 	}
	else if ( isSigSelect3(sig, sel, x, y, z) ) 	{ printGCCall(sig,"generateSelect3");	return generateSelect3 	(sig, sel, x, y, z, priority); 	}
	
    else if ( isProj(sig, &i, x) )                  { printGCCall(sig,"generateRecProj");	return generateRecProj	(sig, x, i, priority);	}
	
	else if ( isSigIntCast(sig, x) ) 				{ printGCCall(sig,"generateIntCast");	return generateIntCast	(sig, x, priority); 	}
	else if ( isSigFloatCast(sig, x) ) 				{ printGCCall(sig,"generateFloatCast");	return generateFloatCast(sig, x, priority); 	}
	
	else if ( isSigButton(sig, label) ) 			{ printGCCall(sig,"generateButton");	return generateButton   (sig, label); 			}
	else if ( isSigCheckbox(sig, label) ) 			{ printGCCall(sig,"generateCheckbox");	return generateCheckbox (sig, label); 			}
	else if ( isSigVSlider(sig, label,c,x,y,z) )	{ printGCCall(sig,"generateVSlider");	return generateVSlider 	(sig, label, c,x,y,z);	}
	else if ( isSigHSlider(sig, label,c,x,y,z) )	{ printGCCall(sig,"generateHSlider");	return generateHSlider 	(sig, label, c,x,y,z);	}
	else if ( isSigNumEntry(sig, label,c,x,y,z) )	{ printGCCall(sig,"generateNumEntry");	return generateNumEntry (sig, label, c,x,y,z);	}
	
	else if ( isSigVBargraph(sig, label,x,y,z) )	{ printGCCall(sig,"generateVBargraph");	return CS(z, priority);}//generateVBargraph 	(sig, label, x, y, CS(z, priority)); }
	else if ( isSigHBargraph(sig, label,x,y,z) )	{ printGCCall(sig,"generateHBargraph");	return CS(z, priority);}//generateHBargraph 	(sig, label, x, y, CS(z, priority)); }
    else if ( isSigAttach(sig, x, y) )				{ printGCCall(sig,"generateAttach");	return generateAttach	(sig, x, y, priority); }
    else if ( isSigEnable(sig, x, y) )				{ printGCCall(sig,"generateEnable");      return generateEnable	(sig, x, y, priority); }

	else {
        stringstream error;
        error << "ERROR in d signal, unrecognized signal : " << *sig << endl;
        throw faustexception(error.str());
	}
    faustassert(0);
	return "error in generate code";
}
Ejemplo n.º 8
0
int SoundGen2GS::readBuffer(int16 *buffer, const int numSamples) {
	static uint data_available = 0;
	static uint data_offset = 0;
	uint n = numSamples << 1;
	uint8 *p = (uint8*)buffer;

	while (n > data_available) {
		memcpy(p, (uint8*)_out + data_offset, data_available);
		p += data_available;
		n -= data_available;

		advancePlayer();

		data_available = generateOutput() << 1;
		data_offset = 0;
	}

	memcpy(p, (uint8*)_out + data_offset, n);
	data_offset += n;
	data_available -= n;

	return numSamples;
}
Ejemplo n.º 9
0
int
main (int argc, const char* const argv[])
{
    char garbage[2];
    int command;
    double sigma;

    if (4 > argc || 5 < argc) {
        fprintf (stderr, 
	         "syntax: %s <input file> <output file> <command #> ...\n", 
	         argv[0]);
        return 2;
    }

    if (1 != sscanf (argv[3], "%d%1s", &command, garbage) || 
        1 > command || 3 < command) {
	fprintf (stderr, "Command must be from 1 to 3.\n");
	fprintf (stderr, "  1 -- gaussian filter   <sigma>\n");
	fprintf (stderr, "  2 -- greyscale\n");
	fprintf (stderr, "  3 -- invert colors\n");
	return 2;
    }

    if (1 == command && 
        (5 != argc ||
         1 != sscanf (argv[4], "%lf%1s", &sigma, garbage) || 
	 0 >= sigma || 100 <= sigma)) {
    	fprintf (stderr, "Sigma must be greater than 0 and less than 100.\n");
	return 2;
    }

    Image* inputImage = decode (argv[1]);
    printf ("Width: %d, height: %d\n", inputImage->width, inputImage->height);
    Image* outputImage = generateOutput (inputImage);

    int height = inputImage->height;
    int width  = inputImage->width;
    uint8_t* inRed    = inputImage->redChannel;
    uint8_t* inBlue   = inputImage->blueChannel;
    uint8_t* inGreen  = inputImage->greenChannel;
    uint8_t* inAlpha  = inputImage->alphaChannel;
    uint8_t* outRed   = outputImage->redChannel;
    uint8_t* outBlue  = outputImage->blueChannel;
    uint8_t* outGreen = outputImage->greenChannel;
    uint8_t* outAlpha = outputImage->alphaChannel;

    switch (command) {
	case 1: {
	    int radius = ceil (3 * sigma);
	    int fSize = 1 + 2 * radius;
	    double* gauss = malloc (sizeof (gauss[0]) * fSize * fSize);
	    gaussianFilter (gauss, sigma);
	    convolveImage (width, height, inRed, inGreen, inBlue, inAlpha, 
			   radius, gauss, outRed, outGreen, outBlue, outAlpha);
	    encode (argv[2], outputImage);
	    break;
	}
	case 2:
	    greyscale (width, height, inRed, inGreen, inBlue, inAlpha, 
	               gMonoMult, outRed, outGreen, outBlue, outAlpha);
	    encode (argv[2], outputImage);
	    break;
	case 3:
	    invertColors (width, height, inRed, inGreen, inBlue, inAlpha, 
	    		  outRed, outGreen, outBlue, outAlpha);
	    encode (argv[2], outputImage);
	    break;
    }

    freeImage (inputImage);
    freeImage (outputImage);

    return 0;
}
Ejemplo n.º 10
0
Result VideoHandle::getDirection()
{
    vector<Point> List;
    Mat frame;
    Mat prev;

    for(int i=10;i--;)
        getUndistortFrame();
    prev = getUndistortFrame();

    while(true)
    {
        int prev_clock = clock();

        frame = getUndistortFrame();
        if(frame.empty()) exit(1);

        Mat temp;
        subtract(prev, frame, temp);
        const Size size = Size(160, 120);
        resize(temp, temp, size, 0, 0, CV_INTER_LINEAR);// FIXME
        cvtColor(temp, temp, CV_BGR2GRAY);
        threshold(temp, temp, 20, 255, CV_THRESH_BINARY);

        Moments m = ::moments(temp);
        Point p = Point(m.m10/m.m00, m.m01/m.m00);

        cout << "Point : " << p.x << " " << p.y << endl;
        List.push_back(p);
        if (p.x < 5 || p.y < 5 || p.x > size.width-5 || p.y > size.height-5) { // FIXME
            cout << "233333333333333" << endl;
            List.clear();
        }

        const int TIMES = 1;// FIXME
        Point sum = Point(0, 0);
        for(int i=1;i<=TIMES;i++)
        {
            if(List.size() < TIMES + 1) continue;
            Point a = List[List.size() - i];
            Point b = List[List.size() - i - 1];
            Point sub = Point(a.x-b.x, a.y-b.y);
            sum.x += sub.x;
            sum.y += sub.y;
        }

        sum.x /= TIMES;
        sum.y /= TIMES;

        cout << "vector : " << sum.x << " " << sum.y << endl;
        if(sum.x*sum.x + sum.y*sum.y >= 30) {    //FIXME 建议修改为||关系
            Result ret = generateOutput(p, Point(p.x+sum.x, p.y+sum.y));
            ret.angle *= -1;
            return ret;
        }

        int now_clock = clock();
        double speed = double(now_clock - prev_clock) / CLOCKS_PER_SEC;
        cout << "speed : " << speed << " " << (1.0/speed) << endl;
    }
}
Ejemplo n.º 11
0
Result VideoHandle::getDirectionPoints()
{
    Mat frame;
    Mat prev;
    vector<Point> List;

	for (int i=30;i--;) getFrame();
    prev = getFrame();

    while(true)
    {
        int prev_clock = clock();

        frame = getFrame();
        if(frame.empty()) break;

        Mat temp;
        subtract(prev, frame, temp);
        const Size size = Size(160, 120);
        resize(temp, temp, size, 0, 0, CV_INTER_LINEAR);
        cvtColor(temp, temp, CV_BGR2GRAY);
        threshold(temp, temp, 20, 255, CV_THRESH_BINARY);

        morphologyEx(temp.clone(), temp, MORPH_OPEN, Mat::ones(3, 3, CV_8U));

        Moments m = ::moments(temp);
        Point p = Point(m.m10/m.m00, m.m01/m.m00);

		// Mat_<Point2f> points(1,1), dst(1,1);
		// points(0) = Point2f(p.x,p.y);
		// undistortPoints(points, dst, distortmtx, distortdist);
		// p.x = - dst(0).y * size.width;
		// p.y = - dst(0).x * size.height;
        cout << "Point : " << p.x << " " << p.y << endl;

        List.push_back(p);
        if (p.x < 5 || p.y < 5 || p.x > size.width - 6 || p.y > size.height - 6) {
            cout << "455555555555555" << endl;
            List.clear();
        }

        const int TIMES = 1;
        Point sum = Point(0, 0);
        for(int i=1;i<=TIMES;i++)
        {
            if(List.size() < TIMES + 1) continue;
            Point a = List[List.size() - i];
            Point b = List[List.size() - i - 1];
            Point sub = Point(a.x-b.x, a.y-b.y);
            sum.x += sub.x;
            sum.y += sub.y;
        }

        sum.x /= TIMES;
        sum.y /= TIMES;

        cout << "vector : " << sum.x << " " << sum.y << endl;
        if(abs(sum.x) >= 2 || abs(sum.y) >= 2) {
            Result ret = generateOutput(p, Point(p.x+sum.x, p.y+sum.y));
            ret.angle *= -1;
            return ret;
        }

        int now_clock = clock();
        double speed = double(now_clock - prev_clock) / CLOCKS_PER_SEC;
        cout << "speed : " << speed << " " << (1.0/speed) << endl;
    }
}
Ejemplo n.º 12
0
Archivo: main.c Proyecto: dyjhhh/dong28
int main(int argc,char *argv[])
{
  //Handles user input
  if(argc<4 || argc>5)
  {
    printf("Incorrect number of arguments\n");
    printf("Number of arguments: %d\n",argc);
    exit(1);
  }

  //const char *inputFilename=argv[1];
  const char *inputFilename=argv[1];
  printf("Inputfile: %s\n",inputFilename);
  const char *outputFilename=argv[2];
  char garbage[2];
  int command;
  double sigma=3;

  if(1!=sscanf(argv[3],"%d%1s",&command,garbage) || command<0 || command>11)
  {
    printf("Incorrect command\n");
    exit(1);
  }

  if(command>0 && command<11 && argc==5)
  {
    printf("Incorrect number of arguments, exclude the sigma value");
    exit(1);
  }

  if(((command==0 || command==11) && argc==5 && 1!=sscanf(argv[4],"%lf%1s",&sigma,garbage)) || sigma<0)
  {
    printf("Incorrect sigma value\n");
    exit(1);
  }

  Filter *filters=initializeFilters(sigma);
  Image *inputImage=decode(inputFilename);
  printf("Width: %d, height: %d\n",inputImage->width,inputImage->height);
  Image *outputImage=generateOutput(inputImage);

  uint8_t *inRed=inputImage->redChannel;
  uint8_t *inBlue=inputImage->blueChannel;
  uint8_t *inGreen=inputImage->greenChannel;
  uint8_t *inAlpha=inputImage->alphaChannel;
  uint8_t *outRed=outputImage->redChannel;
  uint8_t *outBlue=outputImage->blueChannel;
  uint8_t *outGreen=outputImage->greenChannel;
  uint8_t *outAlpha=outputImage->alphaChannel;
  int height=inputImage->height;
  int width=inputImage->width;
  switch(command)
  {
    case(0):
    {
      convolveImage(inRed,inBlue,inGreen,inAlpha,outRed,outBlue,outGreen,
                    outAlpha,filters[0].filter,filters[0].radius,width,height);
      break;
    }
    case(1):
    {
      convolveImage(inRed,inBlue,inGreen,inAlpha,outRed,outBlue,outGreen,
                    outAlpha,filters[1].filter,filters[1].radius,width,height);
      break;
    }
    case(2):
    {
      convolveImage(inRed,inBlue,inGreen,inAlpha,outRed,outBlue,outGreen,
                    outAlpha,filters[2].filter,filters[2].radius,width,height);
      break;
    }
    case(3):
    {
      convolveImage(inRed,inBlue,inGreen,inAlpha,outRed,outBlue,outGreen,
                    outAlpha,filters[3].filter,filters[3].radius,width,height);
      break;
    }
    case(4):
    {
      convolveImage(inRed,inBlue,inGreen,inAlpha,outRed,outBlue,outGreen,
                    outAlpha,filters[4].filter,filters[4].radius,width,height);
      break;
    }
    case(5):
    {
      convolveImage(inRed,inBlue,inGreen,inAlpha,outRed,outBlue,outGreen,
                    outAlpha,filters[5].filter,filters[5].radius,width,height);
      break;
    }
    case(6):
    {
      convolveImage(inRed,inBlue,inGreen,inAlpha,outRed,outBlue,outGreen,
                    outAlpha,filters[6].filter,filters[6].radius,width,height);
      break;
    }
    case(7):
    {
      convertToGray(inRed,inBlue,inGreen,inAlpha,outRed,outBlue,outGreen,
                    outAlpha,gMonoMult,width,height);
      break;
     }
    case(8):
    {
      invertImage(inRed,inBlue,inGreen,inAlpha,outRed,outBlue,outGreen,
                  outAlpha,width,height);
      break;
    }
    case(9):
    {
      flipImage(inRed,inBlue,inGreen,inAlpha,outRed,outBlue,outGreen,
                outAlpha,width,height);
      break;
    }
    case(10):
    {
      pixelate(inRed,inBlue,inGreen,inAlpha,outRed,outBlue,outGreen,
               outAlpha,8,8,width,height);
      break;
    }
    case(11):
    {
      Image *invImage=generateOutput(inputImage);
      Image *blurImage=generateOutput(inputImage);
      pencilSketch(inRed,inBlue,inGreen,inAlpha,invImage->redChannel,
                   invImage->blueChannel,invImage->greenChannel,
                   invImage->alphaChannel,blurImage->redChannel,
                   blurImage->blueChannel,blurImage->greenChannel,
                   blurImage->alphaChannel,outRed,outBlue,outGreen,
                   outAlpha,filters[0].filter,filters[0].radius,width,height,
                   gMonoMult);
      //NOTE THAT I NEED TO FREE EACH OF THE CHANNEL INDIVIDUALLY
      //MAKE A FREE IMAGE FUNCTION
      freeImage(invImage);
      freeImage(blurImage);
      break;
    }
    default:
      exit(1);
  }

  if(command!=12)
    encode(outputFilename,outputImage);

  free((double*)filters[0].filter);
  free(filters);
  freeImage(inputImage);
  freeImage(outputImage);
  return 0;
}
int main(int argc, char **argv)
{
    /*
     * Parse options.
     */
    for (int i = 1; i < argc; i++)
    {
        const char *psz = argv[i];
        if (*psz == '-')
        {
            if (!strcmp(psz, "--output") || !strcmp(psz, "-o"))
            {
                if (++i >= argc)
                {
                    fprintf(stderr, "syntax error: File name expected after '%s'.\n", psz);
                    return RTEXITCODE_SYNTAX;
                }
                g_pszOutput = argv[i];
            }
            else if (!strcmp(psz, "--library") || !strcmp(psz, "-l"))
            {
                if (++i >= argc)
                {
                    fprintf(stderr, "syntax error: Library name expected after '%s'.\n", psz);
                    return RTEXITCODE_SYNTAX;
                }
                g_pszLibrary = argv[i];
            }
            else if (!strcmp(psz, "--explicit-load-function"))
                g_fWithExplictLoadFunction = true;
            else if (!strcmp(psz, "--no-explicit-load-function"))
                g_fWithExplictLoadFunction = false;
            /** @todo Support different load methods so this can be used on system libs and
             *        such if we like. */
            else if (   !strcmp(psz, "--help")
                        || !strcmp(psz, "-help")
                        || !strcmp(psz, "-h")
                        || !strcmp(psz, "-?") )
                return usage(argv[0]);
            else if (   !strcmp(psz, "--version")
                        || !strcmp(psz, "-V"))
            {
                printf("$Revision: 98271 $\n");
                return RTEXITCODE_SUCCESS;
            }
            else
            {
                fprintf(stderr, "syntax error: Unknown option '%s'.\n", psz);
                return RTEXITCODE_SYNTAX;
            }
        }
        else
        {
            if (g_cInputs >= RT_ELEMENTS(g_apszInputs))
            {
                fprintf(stderr, "syntax error: Too many input files, max is %d.\n", (int)RT_ELEMENTS(g_apszInputs));
                return RTEXITCODE_SYNTAX;
            }
            g_apszInputs[g_cInputs++] = argv[i];
        }
    }
    if (g_cInputs == 0)
    {
        fprintf(stderr, "syntax error: No input file specified.\n");
        return RTEXITCODE_SYNTAX;
    }
    if (!g_pszOutput)
    {
        fprintf(stderr, "syntax error: No output file specified.\n");
        return RTEXITCODE_SYNTAX;
    }
    if (!g_pszLibrary)
    {
        fprintf(stderr, "syntax error: No library name specified.\n");
        return RTEXITCODE_SYNTAX;
    }

    /*
     * Do the job.
     */
    RTEXITCODE rcExit = parseInputs();
    if (rcExit == RTEXITCODE_SUCCESS)
        rcExit = generateOutput();
    return rcExit;
}
Ejemplo n.º 14
0
int main (int argc, char *argv[]) 
{
  char *queryString;

  if ((Conf = confp_open(getenv("FUSIONSEQ_CONFPATH"))) == NULL)
    return EXIT_FAILURE;

  cgiInit();
  cgiHeader("text/html");
  queryString = cgiGet2Post();
  if (queryString[0] == '\0') {
    puts ("<html>");
    puts ("<head>");
    html_printGenericStyleSheet (12);
    puts ("<title>geneFusions</title>\n");
    puts ("</head>");
    puts ("<body>");
    puts ("<h1>Identification of potential gene fusions using paired-end reads</h1><br><br>");
    printf ("<form action=%s/geneFusions_cgi method=get>", confp_get(Conf, "WEB_URL_CGI"));
    puts ("<b>Data prefix</b>:&nbsp;");
    puts ("<input type=text name=prefix>");
    puts ("<br><br><br>");
    puts ("<b>Minimum number of paired-end reads connecting two genes</b>:&nbsp;");
    puts ("<select name=minNum>");
    puts ("<option value=2>2");
    puts ("<option value=3>3");
    puts ("<option value=5 selected>5");
    puts ("<option value=10>10");
    puts ("</select>");
    puts ("<br><br><br>");
    puts ("<b>Type of gene fusion</b>:&nbsp;");
    puts ("<select name=type>");
    puts ("<option value=read-through>Read-through events");
    puts ("<option value=cis>Cis events");
    puts ("<option value=intra>Intra-chromosomal events");
    puts ("<option value=same>Genes on the same chromosome");
    puts ("<option value=inter>Genes on different chromosomes");
    puts ("<option value=all selected>All potential gene fusions");
    puts ("</select>");
    puts ("<br><br><br>");
    puts ("<input type=submit value=Submit>");
    puts ("<input type=reset value=Reset>");
    puts ("</form>");
    puts ("</body>");
    puts ("</html>");
    fflush (stdout);
  }
  else {
    int first;
    Stringa item = stringCreate (20);
    Stringa value = stringCreate (20);
    char *iPtr,*vPtr,*prefix,*type;
    int minNum;

    first = 1;
    cgiGetInit ();
    while (cgiGetNextPair (&first,item,value)) {
      iPtr = string (item);
      vPtr = string (value);
      if (strEqual (iPtr,"prefix")) {
	prefix = hlr_strdup (vPtr);
      }
      if (strEqual (iPtr,"type")) {
	type = hlr_strdup (vPtr);
      }
      if (strEqual (iPtr,"minNum")) {
	minNum = atoi (vPtr);
      }
    }
    generateOutput (prefix,type,minNum);
  }
  confp_close(Conf);

  return EXIT_SUCCESS;
}
Ejemplo n.º 15
0
int main(int argc, char *argv[])
{
  parseCommandLineOptions(argc, argv);
  initializeRandomNumberGeneratorTo(rng_seed);
  initializeOutput();
  setInitialConditions();
  if (graphicsModeEnabled()) initializeDisplay();
  
  perturbation_length=fixed_perturbation_length;

  for(monte_carlo_steps=start_mcs; monte_carlo_steps<=end_mcs; monte_carlo_steps++)
  {
    updatePairList();
    generateOutput();
    attempted_moves = 0;
    accepted_moves = 0;

    for (monte_carlo_step_counter=0; monte_carlo_step_counter<number_of_molecules; monte_carlo_step_counter++) 
    {
      double boltzmann_factor;
      double the_exponential;
  
      delta_energy = 0;
      attemptMove();
      attempted_moves++;

      if (delta_energy < 0) 
      {
        change_flag = 1;
        accepted_moves++;
        continue; /* move accepted */
      }

      // the following uses reduced temperature
      the_exponential = 0.0 - delta_energy/temperature;
     /* evaluate exponential, unless it's arbitrarily small */
      if (the_exponential > -25)
      {
        boltzmann_factor = exp(the_exponential);
        if (boltzmann_factor > rnd())
        {
          change_flag = 1;
          accepted_moves++;
          continue; /* move accepted */
        }
      }

      // revert move
      x[particle_number] -= dx;
      y[particle_number] -= dy;
      z[particle_number] -= dz;
    }

    if (monte_carlo_steps < relaxation_allowance) 
    {
      acceptance_ratio = (0.0 + accepted_moves)/(0.0 + attempted_moves);
      if (acceptance_ratio < target_acceptance_ratio) perturbation_length *= .9;
      else if (perturbation_length*perturbation_length*perturbation_length*16 < box_x*box_y*box_z) perturbation_length *=1.1;
    }
    else perturbation_length = fixed_perturbation_length;
    if (graphicsModeEnabled() && changeFlagIsSet()) drawGraphicalRepresentation();
  } 

  finalizeOutput();
  return 0;
} /* end main */
Ejemplo n.º 16
0
Archivo: dog.c Proyecto: ritmatter/dog
int main(int argc, char *argv[]) {
  
  char line[MAXLINE];

  //create an array that keeps track of where switches are
  //initialize it with values of -1
  int isSwitch[argc];
  for (int i = 0; i < argc; i++) {
    isSwitch[i] = -1;
  }
  isSwitch[0] = 1;
  
  //if one of the arguments is --help, print the help page and exit
  for (int i = 1; i < argc; i++) {
    if (strcmp("--help", argv[i]) ==0 ) {
      FILE *help;
      if ((help = fopen("help.txt", "r")) != NULL ) {
	for (;;) {
	  fgets(line, sizeof(line), help);
	  if(feof(help)) {
	    break;
	  }
	  printf("%s", line);
	}
	fclose(help);
      }
      return 0;
    }
  }

  //if there is only one input, then just take standard input
  if (argc == 1) {
    fgets(line, sizeof(line), stdin);
    while (!feof(stdin)) {
      takeInput(line);
      fgets(line, sizeof(line), stdin);
    }
    
    return 0;
  }
    
  //call the function that finds switches
   checkSwitches(argv, isSwitch, argc);

   //check for any errors
   if (error == 1)
     return 1;

   //check for a bad mapfile
   if (badMap == 1) {
      printf("Error: invalid map file.  The map file a list of characters.");
      printf("  Each character must be separated by a space.\n");
      return 1;
   }
   
   //if there are only switches, take standard input
   if (allSwitches(isSwitch, argc) == 1) {
     fgets(line, sizeof(line), stdin);
     while (!feof(stdin)) {
       generateOutput(line);
       fgets(line, sizeof(line), stdin);
     }
     return 0;
   }
   

   /* Now we know there is more than one argument, so we'll go through
      the arguments */
   int z = 1;
   while (z < argc ) {
     
     //make sure that the argument we're on is not a switch
     if ( isSwitch[z] != 1) {
      
       //check if the argument is a hypen or if there are no arguments 
       // except switches, meaning we stop and collect terminal output
       if (argv[z][0] == '-' ) {
	 fgets(line, sizeof(line), stdin);
	 while (!feof(stdin)) {
	   generateOutput(line);
	   fgets(line, sizeof(line), stdin);
	 }
       }

       //if the argument is not a hyphen, it's a file
       else if ((fp = fopen( argv[z], "r")) != NULL ) {
	 for (;;) {
	   fgets(line, sizeof(line), fp);
	   if(feof(fp)) {
	     break;
	   }
	   generateOutput(line);
	 }
	 fclose(fp);
       }

       //otherwise, the argument is an invalid file
       else {
	 printf("Error: No such file %s\n", argv[z]);
	 break;
       }
     }
     z++;    
   }
   return 0;
}