当前位置: 首页>>代码示例>>C++>>正文


C++ StringArray::Read方法代码示例

本文整理汇总了C++中StringArray::Read方法的典型用法代码示例。如果您正苦于以下问题:C++ StringArray::Read方法的具体用法?C++ StringArray::Read怎么用?C++ StringArray::Read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在StringArray的用法示例。


在下文中一共展示了StringArray::Read方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ReadCrossoverRates

bool MarkovParameters::ReadCrossoverRates(const char * filename)
   {
   StringArray tokens;
   StringArray rec;
   rec.Read(filename);

   // Load estimated per marker error rates
   if (rec.Length() == markers)
      {
      printf("  Updating error rates using data in %s ...\n", (const char *) filename);
      for (int i = 0; i < markers; i++)
         {
         tokens.ReplaceTokens(rec[i+1]);

         if (tokens.Length() >= 2) R[i] = tokens[1].AsDouble();
         }

      return true;
      }

   return false;
   }
开发者ID:cfuchsberger,项目名称:minimac,代码行数:22,代码来源:MarkovParameters.cpp

示例2: main

int main(int argc, char ** argv)
   {
   setbuf(stdout, NULL);

   time_t start = time(NULL);

   printf("MiniMac - Imputation into phased haplotypes\n"
          "(c) 2011 Goncalo Abecasis\n");
#ifdef __VERSION__
   printf("VERSION 5.0\n");
#else
   printf("UNDOCUMENTED RELEASE\n");
#endif

   int rounds = 5, states = 200, cpus = 0;
   bool em = false, gzip = false, phased = false;

   String referenceHaplotypes, referenceSnps;
   String haplotypes, snps;
   String prefix("minimac");
   String firstMarker, lastMarker;

   String recombinationRates, errorRates;

   BEGIN_LONG_PARAMETERS(longParameters)
      LONG_PARAMETER_GROUP("Reference Haplotypes")
         LONG_STRINGPARAMETER("refHaps", &referenceHaplotypes)
         LONG_STRINGPARAMETER("refSnps", &referenceSnps)
      LONG_PARAMETER_GROUP("Target Haplotypes")
         LONG_STRINGPARAMETER("haps", &haplotypes)
         LONG_STRINGPARAMETER("snps", &snps)
      LONG_PARAMETER_GROUP("Starting Parameters")
         LONG_STRINGPARAMETER("rec", &recombinationRates)
         LONG_STRINGPARAMETER("erate", &errorRates)
      LONG_PARAMETER_GROUP("Parameter Fitting")
         LONG_INTPARAMETER("rounds", &rounds)
         LONG_INTPARAMETER("states", &states)
         LONG_PARAMETER("em", &em)
      LONG_PARAMETER_GROUP("Output Files")
         LONG_STRINGPARAMETER("prefix", &prefix)
         LONG_PARAMETER("phased", &phased)
         LONG_PARAMETER("gzip", &gzip)
//    LONG_PARAMETER_GROUP("Clipping Window")
//      LONG_STRINGPARAMETER("start", &firstMarker)
//      LONG_STRINGPARAMETER("stop", &lastMarker)
#ifdef _OPENMP
      LONG_PARAMETER_GROUP("Multi-Threading")
         LONG_INTPARAMETER("cpus", &cpus)
#endif
   END_LONG_PARAMETERS();

   ParameterList pl;

   pl.Add(new LongParameters("Command Line Options", longParameters));
   pl.Read(argc, argv);
   pl.Status();

#ifdef _OPENMP
   if (cpus > 0)
      omp_set_num_threads(cpus);
#endif

   // Read marker list
   printf("Reading Reference Marker List ...\n");

   StringArray refMarkerList;
   refMarkerList.Read(referenceSnps);

   // Index markers
   StringIntHash referenceHash;
   for (int i = 0; i < refMarkerList.Length(); i++)
      referenceHash.Add(refMarkerList[i].Trim(), i);

   printf("  %d Markers in Reference Haplotypes...\n\n", refMarkerList.Length());

   // Load reference haplotypes
   printf("Loading reference haplotypes ...\n");
   HaplotypeSet reference;

   reference.markerCount = refMarkerList.Length();
   reference.LoadHaplotypes(referenceHaplotypes);

   printf("  %d Reference Haplotypes Loaded ...\n\n", reference.count);

   // Read framework marker list
   printf("Reading Framework Marker List ...\n");
   StringArray markerList;
   markerList.Read(snps);

   ClipReference(reference, refMarkerList, referenceHash, markerList,
                 firstMarker, lastMarker);

   // Crossref Marker Names to Reference Panel Positions
   IntArray markerIndex;
   markerIndex.Dimension(markerList.Length());

   int matches = 0;

   for (int i = 0; i < markerList.Length(); i++)
      {
//.........这里部分代码省略.........
开发者ID:cfuchsberger,项目名称:minimac,代码行数:101,代码来源:Main.cpp

示例3: ReadModelsFromFile

bool RegressionAnalysis::ReadModelsFromFile()
   {
   StringArray models;
   models.Read(modelsFile);

   if (models.Length() == 0)
      return false;

   regress = new FancyRegression[models.Length()];

   printf("Retrieving analysis models from file [%s]...\n",
          (const char *) modelsFile);

   modelCount = 0;

   StringArray tokens;
   for (int i = 0, line = 0; i < models.Length(); i++)
      {
      models[i].Trim();

      // Skip comments
      if (models[i][0] == '#') continue;

      // Divide each line into tokens
      tokens.Clear();
      tokens.AddTokens(models[i]);

      // Skip blank lines
      if (tokens.Length() == 0) continue;

      // Print message for tracing...
      printf("   Input: %s\n", (const char *) models[i], line++);

      // Need a minimum of four tokens per line
      if (tokens.Length() < 4)
         {
         printf(" Skipped: Trait name, mean, variance and heritability required.\n");
         continue;
         }

      regress[modelCount].trait = ped.LookupTrait(tokens[0]);

      if (regress[modelCount].trait < 0)
         {
         printf(line == 1 ? " Skipped: Appears to be a header line\n" :
                            " Skipped: Trait %s not listed in the data file\n",
                            (const char *) tokens[0]);
         continue;
         }

      // First check that mean, variance and heritability are valid numbers
      bool fail = false;
      for (int j = 1; j <= 3; j++)
         {
         char * ptr = NULL;
         strtod(tokens[j], &ptr);
         fail |= ptr[0] != 0;
         }

      // If one of the values is not a valid number, skip
      if (fail)
         {
         printf(line == 1 ? " Skipped: Appears to be a header line\n" :
                            " Skipped: Invalid numeric format\n");
         continue;
         }

      regress[modelCount].mean = tokens[1];
      regress[modelCount].variance = tokens[2];
      regress[modelCount].heritability = tokens[3];

      if (tokens.Length() > 4)
         {
         regress[modelCount].label = tokens[4];

         for (int j = 5; j < tokens.Length(); j++)
            {
            regress[modelCount].label += " ";
            regress[modelCount].label += tokens[j];
            }
         }
      else
         regress[modelCount].label.printf("Model %d", modelCount + 1);

      regress[modelCount].shortLabel = regress[modelCount].label;
      regress[modelCount].testRetestCorrel = testRetestCorrel;
      regress[modelCount].bounded = !unrestricted;

      printf("        Model loaded and labelled %s\n", (const char *) regress[modelCount].label);

      modelCount++;
      }

   if (modelCount == 0)
      {
      printf("No valid models, default model will be used\n\n");
      return false;
      }

   printf("Table processed. %d models recognized\n\n", modelCount);
//.........这里部分代码省略.........
开发者ID:hilarymartin,项目名称:MAE_project,代码行数:101,代码来源:RegressAnalysis.cpp


注:本文中的StringArray::Read方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。