Exemplo n.º 1
0
TEST(MAPPING, MAPPING3) {
    mkdir("tmp", 0700);
    TemporaryFile file("mapping2", ".dat", "./tmp");
    ASSERT_TRUE(buildDatabase(file.path(), NULL, "./data/refseq.rna.bz2", "./data/gene2refseq_test.txt.bz2", 10, false));

    //frozenhashmap::FrozenMap map;
    //ASSERT_TRUE(map.open(file.path()));

    //mapping
    fprintf(stderr, "Mapping...\n");
    cppfasta::FileWriter fileWriter;
    ASSERT_TRUE(fileWriter.open("tmp/mapping-result.txt"));
    std::map<std::string, int> result;
    std::map<std::string, double> fpkm;
    uint64_t num;

    PFILE *pfile = pipedopen("./data/simulation.fastq.bz2", false);
    ASSERT_TRUE(pfile);
    cppfasta::FastqReader2 reader(pfile->file);
    
    ASSERT_TRUE(domapping(file.path(), &reader, &result, &fpkm, &fileWriter, &num, 1, 1, false, false));
    ASSERT_EQ(493150UL, num);

    pipedclose(pfile);

    for (std::map<std::string, int>::iterator it = result.begin();
         it != result.end(); ++it) {
        fprintf(stderr, "%10s : %d\n", it->first.c_str(), it->second);
    }
    fprintf(stderr, "OK...\n");

    TabTableReader answer_table;
    std::map<std::string, int> answer;
    ASSERT_TRUE(answer_table.open("./data/python-mapping-result.txt"));
    answer_table.next(); // skip header
    std::vector<std::string> row;
    while ((row = answer_table.next()).size() >= 2) {
        char *endptr;
        long num = strtol(row[1].c_str(), &endptr, 10);
        ASSERT_EQ('\0', *endptr);
        ASSERT_EQ(num, result[row[0]]) << row[0];
        //DEBUG("%s %ld %ld", row[0].c_str(), num, result[row[0]]);

        if (row[0] != "UNMAPPED" || row[0] != "MULTIMAPPED") {
            char *endptr;
            double fpkm_expected = strtod(row[2].c_str(), &endptr);
            ASSERT_EQ('\0', *endptr);
            //fprintf(stderr, "FPKM Expected[%s]: %lf  Result: %lf\n", row[0].c_str(), fpkm_expected, fpkm[row[0]]);
            ASSERT_NEAR(fpkm_expected, fpkm[row[0]], 1e-19) << "GeneID " << row[0];
        }
    }
}
Exemplo n.º 2
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow),
    m_settings(),
    m_databaseOK(false),
    m_tuloksia(0),
    m_kilpailijoita(0),
    m_tuloksiaLabel(new QLabel(this)),
    m_serialStatus(new QLabel(this)),
    m_testEmitReader(0),
    m_serialEmitReader(new SerialEmitReaderWidget()),
    m_pikanappaimetForm(0),
    m_vuokraEmititForm(0),
    m_tulosnayttoForm(0)
{
    ui->setupUi(this);

    connect(m_serialEmitReader, SIGNAL(readEmit(QDateTime,QString,int,int,QList<RastiData>)),
            this, SLOT(handleReadEmit(QDateTime,QString,int,int,QList<RastiData>)));
    connect(m_serialEmitReader, SIGNAL(statusChanged(QString)),
            m_serialStatus, SLOT(setText(QString)));

    connect(ui->menuSarjaportti, SIGNAL(aboutToShow()),
            this, SLOT(setupSerialMenu()));

    connect(ui->menuSarjaportti, SIGNAL(triggered(QAction*)),
            this, SLOT(handleSerialMenu(QAction*)));

    connectDatabase();
    buildDatabase();

    if (!Tietokanta::checkVersion(MAJOR_VERSION)) {
        QString v = Tietokanta::getVersion();

        if (QMessageBox::question(this, _("Tulospalvelu - " VERSION),
                                  _("Tietokanta (%1) ei ole yhteensopiva. Haluatko jatkaa?")
                                  .arg(v),
                              QMessageBox::Yes | QMessageBox::No,
                              QMessageBox::No) != QMessageBox::Yes) {
            return;
        }
    }

    setupTapahtuma();

    setupShortcuts();
}
Exemplo n.º 3
0
//#pragma argsused
short PD_style _Ask_AsqlSys( OpndType *lpOpnd, short ParaNum, short *OpndTop, \
		short *CurState )
// OpndType *lpOpnd;               pointer of opnd stack
// short ParaNum;                  parameter number for this action
// short *OpndTop;                 system opnd top
// short *CurState;                the action sequence working state
{
    char  parameter[256];
    char  *sz;
    short sysFunNo;
    int   i;
extern WSToMT FromToStru fFrTo;

    switch( lpOpnd[0].type ) {
	    case LONG_TYPE:
		 sysFunNo = (short)*(long *)lpOpnd[0].values;
		 break;
	    case INT_TYPE:
		 sysFunNo = *(short *)lpOpnd[0].values;
		 break;
	    case CHR_TYPE:
		 sysFunNo = (short)*(char *)lpOpnd[0].values;
		 break;
	    default:
		 sysFunNo = 0;
    }

    switch( sysFunNo ) {
	    case 3001:
	    {
	    //
	    //build hzth
	    //
		char *s;
		char  buf[MAXPATH];

		s = GetCfgKey(csuDataDictionary, "SYSTEM", NULL, "CODE");
		if( s != NULL ) {
		    strZcpy(buf, s, MAXPATH);
		    if( hBuildCodeLib(buf) != 1 )
		    {
			strZcpy(ErrorSet.string, buf, XES_LENGTH);
			return  1;
		    }
		    if( hOpen(buf) != 1 )
		    {
			strZcpy(ErrorSet.string, buf, XES_LENGTH);
			return  1;
		    }
		}
		*OpndTop -= ParaNum;    /* maintain the opnd stack */
		return( 0 );
	    }

	    //
	    //secret
	    //
	    case 32123:
	    {
		//if( stricmp(asqlEnv.szUser, "ADMIN") == 0 )
		{
		   dictDupFile();
		}
		*OpndTop -= ParaNum;    /* maintain the opnd stack */
		return( 0 );
	    }

	    //
	    //secret
	    //
	    case 32124:
	    {
		//if( stricmp(asqlEnv.szUser, "ADMIN") == 0 )
		{
		    dictReopenCfgFile();
		}
		*OpndTop -= ParaNum;    /* maintain the opnd stack */
		return( 0 );
	    }
    };

    sz = xGetOpndString(&lpOpnd[1]);
    if( sz == NULL )
	parameter[0] = '\0';
    else
	strZcpy(parameter, sz, 255);

    switch( sysFunNo ) {
	    case 1:
#ifndef _WINDOWS_
#ifdef FOR_TGMIS
		systemCall(parameter);
#else
		system(parameter);
#endif
#else
{
	STARTUPINFO si;
	PROCESS_INFORMATION pi;
	HANDLE  hProcess;
	DWORD	dwExitCode;


	_try {
		ZeroMemory(&si, sizeof(STARTUPINFO));
		si.cb = sizeof(si);
		si.wShowWindow = SW_HIDE;
		if( CreateProcess(NULL, parameter, NULL, NULL, TRUE, 0, NULL, NULL, &si, &pi) )
		{
			hProcess = pi.hProcess;
			CloseHandle(pi.hThread);
			if( WaitForSingleObject(hProcess, INFINITE) != WAIT_FAILED ) {
				GetExitCodeProcess(hProcess, &dwExitCode);
				CloseHandle(hProcess);
			}
		} else {
			//ErrorSet.xERROR = GetLastError();
			dwExitCode = FormatMessage(
				    FORMAT_MESSAGE_IGNORE_INSERTS |FORMAT_MESSAGE_FROM_SYSTEM, \
				    NULL,
				    GetLastError(),
				    MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // default language
				    parameter,
				    256,
				    NULL );
			strZcpy(ErrorSet.string, parameter, XES_LENGTH);
			return  1;
		}
	}
	
	_except( EXCEPTION_EXECUTE_HANDLER ) {
	    return  1;
	}
}
#endif
		break;
	    case 2:
		mkdirs(parameter);
		break;
	    case 3:
		unlink(parameter);
		break;
	    case 10:
		buildDatabase(parameter);
		break;
	    case 11:
		dropDatabase(parameter);
		break;
	    case 100:
		uncatchTable(parameter);
		break;

	    case 2001:
	    {
	    //
	    //create index parameter on fFrTo.cSouDbfNum[i] (lpOpnd[3])
	    //
		if( ParaNum < 4 ) {
			ErrorSet.xERROR = iSysParaErr;
			return  1;
		}

		i = xGetOpndLong(&lpOpnd[2]) - 1;

		if( i < 0 || i >= fFrTo.cSouDbfNum ) {
			ErrorSet.xERROR = iSysParaErr;
			return  1;
		}

		sz = xGetOpndString(&lpOpnd[3]);

		if( fFrTo.AsqlDatabase[0] == '\0' ) {
		    buildIndexAndRegThem("DBROOT", fFrTo.cSouFName[i], parameter, sz);
		} else {
		    buildIndexAndRegThem(fFrTo.AsqlDatabase, fFrTo.cSouFName[i], parameter, sz);
		}

		break;
	    }

	    case 2002:
	    {
	    //
	    //drop index parameter on fFrTo.cSouDbfNum[i]
	    //
		if( ParaNum < 3 ) {
			ErrorSet.xERROR = iSysParaErr;
			return  1;
		}

		i = xGetOpndLong(&lpOpnd[2]) - 1;

		if( i < 0 || i >= fFrTo.cSouDbfNum ) {
			ErrorSet.xERROR = iSysParaErr;
			return  1;
		}

		if( fFrTo.AsqlDatabase[0] == '\0' ) {
		    dropIndexAndRegThem("DBROOT", fFrTo.cSouFName[i], parameter);
		} else {
		    dropIndexAndRegThem(fFrTo.AsqlDatabase, fFrTo.cSouFName[i], parameter);
		}
		break;
	    }
    }

    *OpndTop -= ParaNum;    /* maintain the opnd stack */

    return( 0 );

} /* end of function _Ask_AsqlSys() */