Beispiel #1
0
void Tests::TestFromCommandLine(int argc, char **argv)
{
    FGLogger logger;
    logger.Begin(FGLogger::Output, "Use FundGroup --help for more info");

    ProcessArguments(argc, argv);
    logger.Log(FGLogger::Output)<<"complex type: "<<complexType<<std::endl;
    logger.Log(FGLogger::Output)<<"reduction type: "<<reductionType<<std::endl;
    logger.Log(FGLogger::Output)<<"input: "<<inputFilename<<std::endl;

    IFundGroup* fg = CreateFundGroupAlgorithm();
    logger.Log(FGLogger::Output)<<*fg<<std::endl;

    if (hapProgramFilename != "")
    {
        fg->ExportHapProgram(hapProgramFilename.c_str());
    }

    delete fg;
    logger.End();
}
Beispiel #2
0
int main(int argc, const char **argv) {
  Parameters par(argc, argv);

  strcpy(par.infile, "");
  strcpy(par.outfile, "");

  // maximum number of sequences to be written
  par.nseqdis = par.maxseq - 1;
  // no filtering for maximum diversity
  par.Ndiff = 0;

  ProcessArguments(par);

  // Check command line input and default values
  if (!*par.infile) {
    help(par);
    HH_LOG(ERROR) << "Input file is missing!" << std::endl;
    exit(4);
  }
  if (!*par.outfile) {
    help(par);
    HH_LOG(ERROR) << "Output file is missing!" << std::endl;
    exit(4);
  }

  HH_LOG(INFO) << "Input file = " << par.infile << "\n";
  HH_LOG(INFO) << "Output file = " << par.outfile << "\n";

  // Reads in an alignment from par.infile into matrix X[k][l] as ASCII
  FILE* inf = NULL;
  if (strcmp(par.infile, "stdin")) {
    inf = fopen(par.infile, "r");
    if (!inf) {
      OpenFileError(par.infile, __FILE__, __LINE__, __func__);
    }
  }
  else {
    inf = stdin;
  }

  Alignment qali(par.maxseq, par.maxres);
  qali.Read(inf, par.infile, par.mark, par.maxcol, par.nseqdis);
  fclose(inf);

  // Convert ASCII to int (0-20),throw out all insert states, record their number in I[k][i]
  // and store marked sequences in name[k] and seq[k]
  qali.Compress(par.infile, par.cons, par.maxcol, par.M, par.Mgaps);

  // substitution matrix flavours
  float __attribute__((aligned(16))) P[20][20];
  float __attribute__((aligned(16))) R[20][20];
  float __attribute__((aligned(16))) Sim[20][20];
  float __attribute__((aligned(16))) S[20][20];
  float __attribute__((aligned(16))) pb[21];
  SetSubstitutionMatrix(par.matrix, pb, P, R, S, Sim);

  // Remove sequences with seq. identity larger than seqid percent (remove the shorter of two)
  qali.N_filtered = qali.Filter(par.max_seqid, S, par.coverage, par.qid, par.qsc,par.Ndiff);

  // Atune alignment diversity q.Neff with qsc to value Neff_goal
  if (par.Neff >= 1.0) {
    qali.FilterNeff(par.wg, par.mark, par.cons, par.showcons, par.max_seqid, par.coverage, par.Neff, pb, S, Sim);
  }

  // Write filtered alignment WITH insert states (lower case) to alignment file
  qali.WriteToFile(par.outfile, par.append);
}
Beispiel #3
0
int C_DECL main(int argc, char* argv[])
{
    ProcessArguments(argc, argv);

    if (Options & EOptionDumpConfig) {
        printf("%s", DefaultConfig);
        if (Worklist.empty())
            return ESuccess;
    }

    if (Options & EOptionDumpVersions) {
        printf("Glslang Version: %s %s\n", GLSLANG_REVISION, GLSLANG_DATE);
        printf("ESSL Version: %s\n", glslang::GetEsslVersionString());
        printf("GLSL Version: %s\n", glslang::GetGlslVersionString());
        std::string spirvVersion;
        glslang::GetSpirvVersion(spirvVersion);
        printf("SPIR-V Version %s\n", spirvVersion.c_str());
        printf("GLSL.std.450 Version %d, Revision %d\n", GLSLstd450Version, GLSLstd450Revision);
        if (Worklist.empty())
            return ESuccess;
    }

    if (Worklist.empty()) {
        usage();
    }

    ProcessConfigFile();

    //
    // Two modes:
    // 1) linking all arguments together, single-threaded, new C++ interface
    // 2) independent arguments, can be tackled by multiple asynchronous threads, for testing thread safety, using the old handle interface
    //
    if (Options & EOptionLinkProgram ||
        Options & EOptionOutputPreprocessed) {
        glslang::InitializeProcess();
        CompileAndLinkShaders();
        glslang::FinalizeProcess();
    } else {
        ShInitialize();

        bool printShaderNames = Worklist.size() > 1;

        if (Options & EOptionMultiThreaded) {
            const int NumThreads = 16;
            void* threads[NumThreads];
            for (int t = 0; t < NumThreads; ++t) {
                threads[t] = glslang::OS_CreateThread(&CompileShaders);
                if (! threads[t]) {
                    printf("Failed to create thread\n");
                    return EFailThreadCreate;
                }
            }
            glslang::OS_WaitForAllThreads(threads, NumThreads);
        } else
            CompileShaders(0);

        // Print out all the resulting infologs
        for (int w = 0; w < NumWorkItems; ++w) {
            if (Work[w]) {
                if (printShaderNames)
                    PutsIfNonEmpty(Work[w]->name.c_str());
                PutsIfNonEmpty(Work[w]->results.c_str());
                delete Work[w];
            }
        }

        ShFinalize();
    }

    if (CompileFailed)
        return EFailCompile;
    if (LinkFailed)
        return EFailLink;

    return 0;
}
Beispiel #4
0
int main(int argc, char* argv[]){
	t_Plane* pWorkArea;
	t_Point* pCoinPoint;
	/* Set coin point memory. */
	pCoinPoint = (t_Point*)malloc(sizeof(t_Point));
	/* Set working area memory. */
	pWorkArea = (t_Plane*)malloc(sizeof(t_Plane));
	if(pWorkArea == NULL){
		perror("Memory allocated wrong.\n");
		return -1;
	}
	pWorkArea->pLine = \
		(t_Line*)malloc(sizeof(t_Line)*(TOP_LEFT_UARM_Y-BOTTOM_LEFT_UARM_Y+1));
	if(pWorkArea->pLine == NULL){
		perror("Memory allocated wrong.\n");
		return -1;
	}
	pWorkArea->pLine->pPoint = \
		(t_Point*)malloc(sizeof(t_Point)*(TOP_LEFT_UARM_Y-BOTTOM_LEFT_UARM_Y+1) \
										*(BOTTOM_RIGHT_UARM_X-BOTTOM_LEFT_UARM_X+1));
	if(pWorkArea->pLine->pPoint == NULL){
		perror("Memory allocated wrong.\n");
		return -1;
	}
	/* Pass the arguments. */
	if(ProcessArguments(argc, argv, pWorkArea, pCoinPoint)<0){
		perror("Input arguments are wrong.\n");
		return -2;
	}
	/* Insert referance points's uArm location. */
	pWorkArea->BottomLeftPoint.UarmX = BOTTOM_LEFT_UARM_X;
	pWorkArea->BottomLeftPoint.UarmY = BOTTOM_LEFT_UARM_Y;
	pWorkArea->BottomRightPoint.UarmX = BOTTOM_RIGHT_UARM_X;
	pWorkArea->BottomRightPoint.UarmY = BOTTOM_RIGHT_UARM_Y;
	pWorkArea->TopLeftPoint.UarmX = TOP_LEFT_UARM_X;
	pWorkArea->TopLeftPoint.UarmY = TOP_LEFT_UARM_Y;
	pWorkArea->TopRightPoint.UarmX = TOP_RIGHT_UARM_X;
	pWorkArea->TopRightPoint.UarmY= TOP_RIGHT_UARM_Y;
	#ifdef DEBUG
	PointPrint("Bottom left point", &pWorkArea->BottomLeftPoint);
	PointPrint("Bottom right point", &pWorkArea->BottomRightPoint);
	PointPrint("Top left point", &pWorkArea->TopLeftPoint);
	PointPrint("Top right point", &pWorkArea->TopRightPoint);
	#endif
	/* Draw the working area. */
	if(RectengularAreaDraw(pWorkArea) < 0){
		perror("Area initialization wrong.\n");
		return -3;
	}
	#ifdef DEBUG
	printf("Area initialization OK.\n");
	printf("Work area's lines number is %d.\n",pWorkArea->LineNumber);
	#endif
	/* Locate the coin */
	if(CoinLocation(pCoinPoint, pWorkArea) < 0){
		perror("Coin location wrong.\n");
		return -3;
	}
	PointPrint("Coin", pCoinPoint);
	/* Wirte all point map to file:point_map. */
	if(WritePointsMap(pWorkArea) < 0){
		perror("Points map generation wrong.\n");
		return -4;
	}
	/* Free the memory. */
	free(pCoinPoint);
	free(pWorkArea->pLine->pPoint);
	free(pWorkArea->pLine);
	free(pWorkArea);
	return 0;
}
Beispiel #5
0
int main (int argc, const char ** argv)
{

    
    ProgramArgument program_args=ProcessArguments(argc,argv);
    
    
    bool print_ali=program_args.print_ali;

    ParseMatrix submatParser(program_args.matrixname);
#ifdef DEBUG
    std::cout << "Print Matrix\n";
    submatParser.print();
#endif
    SubstitutionMatrix subMatrix(submatParser.scores, submatParser.row_index);
#ifdef DEBUG
    std::cout << "Print SubMatrix!\n";
    subMatrix.print();
#endif
    SequenceLibrary sequences(program_args.seqlib);
    const size_t max_seq_size = sequences.get_max_seq_size();
    PairsLibrary pairs(program_args.pairs,&sequences);
    GotohEight gotohAlgo(max_seq_size,&subMatrix, program_args.go, program_args.ge, program_args.mode);
    SequenceEight sequenceQuery(max_seq_size, subMatrix.aa2short,subMatrix.short2aa);
    SequenceEight sequenceTemplate(max_seq_size, subMatrix.aa2short,subMatrix.short2aa);

    
        
    char buffer[2097152];
    std::cout.rdbuf()->pubsetbuf(buffer, 2097152);
    
    const char ** template_sequences=(const char **)memalign(16,(VEC_SIZE)*sizeof(const char *)); 
    const char ** template_keys=(const char **)memalign(16,(VEC_SIZE)*sizeof(const char *)); 
    
    std::map< std::string,std::vector<std::pair<std::string,size_t> > >::iterator it = pairs.pairs.begin();    
    for( ; it != pairs.pairs.end(); ++it ){
        std::pair<std::string, size_t> query = sequences.get_sequence(it->first);
        std::string query_key = it->first.c_str();
        sequenceQuery.MapOneSEQToSEQ8(query.first.c_str());
        std::vector<std::pair<std::string, size_t> > t_seq = it->second;
        sort (t_seq.begin(), t_seq.end(), sort_seq_vector); 

        int elem_count=0;
        size_t t_seq_size = t_seq.size();
        for(std::vector<int>::size_type i = 0; i < t_seq_size ; i++) {
            std::string template_key=t_seq[i].first;
            template_keys[i%VEC_SIZE] = template_key.c_str();
            template_sequences[i%VEC_SIZE] = sequences.get_sequence(template_key).first.c_str();
            elem_count++;
            if((i+1)%VEC_SIZE==0){
                elem_count=0;
                sequenceTemplate.MapSEQArrayToSEQ8(template_sequences, VEC_SIZE);
                GotohEight::GotohMatrix matrix= gotohAlgo.calc_matrix(&sequenceQuery, &sequenceTemplate);
                if(print_ali == true){
                    std::vector<char *> alignments=gotohAlgo.backtrace(matrix,&sequenceQuery,&sequenceTemplate);
                        for(size_t i = 0; i < 8; i++) {
                            if(program_args.check==true){
                                float check_score=gotohAlgo.calc_check_score(alignments[(i*2)],alignments[(i*2)+1]);
                                printf("check score: %.3f\n",check_score);
                            }
                            print_ali_result(alignments[(i*2)],alignments[(i*2)+1],matrix.score[i],query_key,template_keys[i]);
                        }
                }else{    
                    print_score(matrix,query_key,template_keys,VEC_SIZE);
                }
            }
            
        }
        if(elem_count!=0){
            sequenceTemplate.MapSEQArrayToSEQ8(template_sequences, elem_count);
            GotohEight::GotohMatrix matrix= gotohAlgo.calc_matrix(&sequenceQuery, &sequenceTemplate);
            if(print_ali == true){
                std::vector<char *> alignments=gotohAlgo.backtrace(matrix,&sequenceQuery,&sequenceTemplate);
                for(size_t i = 0; i < elem_count; i++) {
                    if(program_args.check==true){
                        float check_score=gotohAlgo.calc_check_score(alignments[(i*2)],alignments[(i*2)+1]);
                        printf("check score: %.3f\n",check_score);
                    }
                print_ali_result(alignments[(i*2)],alignments[(i*2)+1],matrix.score[i],query_key,template_keys[i]);
                }
            }else{    
                print_score(matrix,query_key,template_keys,elem_count);
            }
        }
        
    }
    std::cout.flush();
    free(template_keys);
    free(template_sequences);
    
    
    
    
    return 0;
}
Beispiel #6
0
/////////////////////////////////////////////////////////////////////////////////////
//// MAIN PROGRAM
/////////////////////////////////////////////////////////////////////////////////////
int main(int argc, char **argv) {
    char* argv_conf[MAXOPT]; // Input arguments from .hhdefaults file (first=1: argv_conf[0] is not used)
    int argc_conf;               // Number of arguments in argv_conf

    strcpy(par.infile, "");
    strcpy(par.outfile, "");
    strcpy(par.alnfile, "");

    //Default parameter settings
    par.nseqdis = MAXSEQ - 1;        // maximum number of sequences to be written
    par.showcons = 0;
    par.cons = 1;
    par.Ndiff = 0;
    par.max_seqid = 100;
    par.coverage = 0;
    par.pc_hhm_context_engine.pca = 0.0;  // no amino acid pseudocounts
    par.pc_hhm_nocontext_a = 0.0;  // no amino acid pseudocounts
    par.gapb = 0.0; // no transition pseudocounts

    // Make command line input globally available
    par.argv = argv;
    par.argc = argc;
    RemovePathAndExtension(program_name, argv[0]);

    // Enable changing verbose mode before defaults file and command line are processed
    int v = 2;
    for (int i = 1; i < argc; i++) {
        if (!strcmp(argv[i], "-def"))
            par.readdefaultsfile = 1;
        else if (strcmp(argv[i], "-v") == 0) {
            v = atoi(argv[i + 1]);
        }
    }
    par.v = Log::from_int(v);
    Log::reporting_level() = par.v;

    par.SetDefaultPaths();

    // Read .hhdefaults file?
    if (par.readdefaultsfile) {
        // Process default otpions from .hhconfig file
        ReadDefaultsFile(argc_conf, argv_conf);
        ProcessArguments(argc_conf, argv_conf);
    }

    // Process command line options (they override defaults from .hhdefaults file)
    ProcessArguments(argc, argv);

    Alignment* qali = new Alignment(MAXSEQ, par.maxres);
    HMM* q = new HMM(MAXSEQDIS, par.maxres);        //Create a HMM with maximum of par.maxres match states

    // q is only available after maxres is known, so we had to move this here
    for (int i = 1; i <= argc - 1; i++) {
        if (!strcmp(argv[i], "-name") && (i < argc - 1)) {
            strmcpy(q->name, argv[++i], NAMELEN - 1); //copy longname to name...
            strmcpy(q->longname, argv[i], DESCLEN - 1);   //copy full name to longname
        }
    }

    // Check command line input and default values
    if (!*par.infile) {
        help();
        HH_LOG(ERROR) << "Input file is missing!" << std::endl;
        exit(4);
    }

    // Get basename
    RemoveExtension(q->file, par.infile); //Get basename of infile (w/o extension):

    // Outfile not given? Name it basename.hhm
    if (!*par.outfile && !*par.alnfile) {
        RemoveExtension(par.outfile, par.infile);
        strcat(par.outfile, ".seq");
    }

    // Prepare CS pseudocounts lib
    if (!par.nocontxt && *par.clusterfile) {
        InitializePseudocountsEngine(par, context_lib, crf, pc_hhm_context_engine,
                                     pc_hhm_context_mode, pc_prefilter_context_engine,
                                     pc_prefilter_context_mode);
    }

    // Set substitution matrix; adjust to query aa distribution if par.pcm==3
    SetSubstitutionMatrix(par.matrix, pb, P, R, S, Sim);

    // Read input file (HMM, HHM, or alignment format), and add pseudocounts etc.
    char input_format = 0;
    ReadQueryFile(par, par.infile, input_format, par.wg, q, qali, pb, S, Sim);

    // Same code as in PrepareQueryHMM(par.infile,input_format,q,qali), except that we add SS prediction
    // Add Pseudocounts, if no HMMER input
    if (input_format == 0) {
        // Transform transition freqs to lin space if not already done
        q->AddTransitionPseudocounts(par.gapd, par.gape, par.gapf, par.gapg,
                                     par.gaph, par.gapi, par.gapb, par.gapb);

        // Comput substitution matrix pseudocounts
        if (par.nocontxt) {
            // Generate an amino acid frequency matrix from f[i][a] with full pseudocount admixture (tau=1) -> g[i][a]
            q->PreparePseudocounts(R);
            // Add amino acid pseudocounts to query: p[i][a] = (1-tau)*f[i][a] + tau*g[i][a]
            q->AddAminoAcidPseudocounts(par.pc_hhm_nocontext_mode,
                                        par.pc_hhm_nocontext_a, par.pc_hhm_nocontext_b,
                                        par.pc_hhm_nocontext_c);
        }
        else {
            // Add full context specific pseudocounts to query
            q->AddContextSpecificPseudocounts(pc_hhm_context_engine,
                                              pc_hhm_context_mode);
        }
    }
    else {
        q->AddAminoAcidPseudocounts(0, par.pc_hhm_nocontext_a,
                                    par.pc_hhm_nocontext_b, par.pc_hhm_nocontext_c);
    }

    q->CalculateAminoAcidBackground(pb);

    if (par.columnscore == 5 && !q->divided_by_local_bg_freqs)
        q->DivideBySqrtOfLocalBackgroundFreqs(
            par.half_window_size_local_aa_bg_freqs, pb);

    // Write consensus sequence to sequence file
    // Consensus sequence is calculated in hhalignment.C, Alignment::FrequenciesAndTransitions()
    if (*par.outfile) {
        FILE* outf = NULL;
        if (strcmp(par.outfile, "stdout")) {
            outf = fopen(par.outfile, "a");
            if (!outf)
                OpenFileError(par.outfile, __FILE__, __LINE__, __func__);
        }
        else
            outf = stdout;
        // OLD
        //// ">name_consensus" -> ">name consensus"
        //strsubst(q->sname[q->nfirst],"_consensus"," consensus");
        //fprintf(outf,">%s\n%s\n",q->sname[q->nfirst],q->seq[q->nfirst]+1);
        // NEW (long header needed for NR30cons database)
        fprintf(outf, ">%s\n%s\n", q->longname, q->seq[q->nfirst] + 1);
        fclose(outf);
    }

    // Print A3M/A2M/FASTA output alignment
    if (*par.alnfile) {
        HalfAlignment qa;
        int n = imin(q->n_display,
                     par.nseqdis + (q->nss_dssp >= 0) + (q->nss_pred >= 0)
                     + (q->nss_conf >= 0) + (q->ncons >= 0));
        qa.Set(q->name, q->seq, q->sname, n, q->L, q->nss_dssp, q->nss_pred,
               q->nss_conf, q->nsa_dssp, q->ncons);

        if (par.outformat == 1)
            qa.BuildFASTA();
        else if (par.outformat == 2)
            qa.BuildA2M();
        else if (par.outformat == 3)
            qa.BuildA3M();
        if (qali->readCommentLine)
            qa.Print(par.alnfile, par.append, qali->longname); // print alignment to outfile
        else
            qa.Print(par.alnfile, par.append);   // print alignment to outfile
    }

    delete qali;
    delete q;

    DeletePseudocountsEngine(context_lib, crf, pc_hhm_context_engine,
                             pc_hhm_context_mode, pc_prefilter_context_engine,
                             pc_prefilter_context_mode);
}
int wmain(int iArgCnt, WCHAR ** argv)
{

    if(!ProcessArguments(iArgCnt, argv))
    {
        DisplayOptions();
        return 1;
	}

	if (wcslen(wServerName) > 0)
	{
		
		
		//prompt for credentials for a remote connection

		DWORD dwRes = CredUICmdLinePromptForCredentialsW(
									(const WCHAR *) wServerName, NULL, 0, 
									wFullUserName, sizeof(wFullUserName)/sizeof(WCHAR),
									wPassWord, sizeof(wPassWord)/sizeof(WCHAR),
									FALSE, 
									CREDUI_FLAGS_EXCLUDE_CERTIFICATES | CREDUI_FLAGS_DO_NOT_PERSIST );

		if (dwRes != NO_ERROR)
		{
			printf("Failed to retrieve credentials: error %d. Using the default credentials.", dwRes);
		}
		
		bUserNameSet = bPassWordSet = (dwRes == NO_ERROR);

	}
	else
	{
		//no server name passed in, assume local
		StringCbCopyW(wServerName, sizeof(wPath), L".");
	}

	StringCbCopyW(wPath, sizeof(wPath), L"\\\\");
	StringCbCatW(wPath, sizeof(wPath),  wServerName);
	StringCbCatW(wPath, sizeof(wPath),  L"\\");
	StringCbCatW(wPath, sizeof(wPath),  wNameSpace);
          
    IWbemLocator *pLocator = NULL;
    IWbemServices *pNamespace = 0;
    IWbemClassObject * pClass = NULL;

    // Initialize COM.

    HRESULT hr = CoInitialize(0);
	if (FAILED(hr))
	{
	    printf("\nCoInitialize returned 0x%x:", hr);
		return 1;
	}

    // This sets the default impersonation level to "Impersonate" which is what WMI 
	// providers will generally require. 
    //
    // DLLs cannot call this function.  To bump up the impersonation level, they must 
    // call CoSetProxyBlanket which is illustrated later on.  
	//  
	//  When using asynchronous WMI API's remotely in an environment where the "Local System" account 
	//  has no network identity (such as non-Kerberos domains), the authentication level of 
	//  RPC_C_AUTHN_LEVEL_NONE is needed. However, lowering the authentication level to 
	//  RPC_C_AUTHN_LEVEL_NONE makes your application less secure. It is wise to
	//	use semi-synchronous API's for accessing WMI data and events instead of the asynchronous ones.
    
    hr = CoInitializeSecurity(NULL, -1, NULL, NULL,
                                RPC_C_AUTHN_LEVEL_PKT_PRIVACY,
                                RPC_C_IMP_LEVEL_IMPERSONATE,
                                NULL, 
								EOAC_SECURE_REFS, //change to EOAC_NONE if you change dwAuthnLevel to RPC_C_AUTHN_LEVEL_NONE
								0);
	if (FAILED(hr))
	{
	    printf("\nCoInitializeSecurity returned 0x%x:", hr);
		return 1;
	}
                                
    hr = CoCreateInstance(CLSID_WbemLocator, 0, CLSCTX_INPROC_SERVER,
            IID_IWbemLocator, (LPVOID *) &pLocator);

	if (FAILED(hr))
	{
	    printf("\nCoCreateInstance for CLSID_WbemLocator returned 0x%x:", hr);
		return 1;
	}
   
    hr = pLocator->ConnectServer(wPath, 
                    (bUserNameSet) ? wFullUserName : NULL, 
                    (bPassWordSet) ? wPassWord : NULL, 
                    NULL, 0, NULL, NULL, &pNamespace);
    if(FAILED(hr))
    {
        wprintf(L"\nConnectServer  to %s failed, hr = 0x%x", wPath, hr);
    }
    else
    {
        printf("\nConnection succeeded");
        hr = SetProxySecurity(pNamespace);
        if(SUCCEEDED(hr))
        {
            ListClasses(pNamespace);
            ReadACL(pNamespace);
        }
        pNamespace->Release();
    }
    CoUninitialize();
    printf("\nTerminating normally");
    return 0;
}