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


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

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


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

示例1: ClipReference

void ClipReference(HaplotypeSet  & reference,
                   StringArray   & refMarkerList,
                   StringIntHash & referenceHash,
                   StringArray   & markerList,
                   String & start, String & stop)
   {
   if (start == "start") start.Clear();
   if (stop == "stop") stop.Clear();

   // If no clipping was requested, then nothing to do
   if (start.IsEmpty() && stop.IsEmpty())
       return;

   // Find the stretch of target that overlaps with reference
   int    firstMatch = reference.markerCount, lastMatch = -1;
   bool   matchStart = false, matchStop = false;
   String newStart, newStop;

   // First we find overlapping markers in target and, at the same time,
   // keep track of the marker nearest suggested start and stop positions
   // that overlaps with reference.
   for (int i = 0; i < markerList.Length(); i++)
      {
      String trimmed = markerList[i].Trim();

      if (start == trimmed) matchStart = true;
      if (stop == trimmed) matchStop = true;

      int index = referenceHash.Integer(trimmed);

      if (index < 0) continue;

      if (index < firstMatch) firstMatch = index;
      if (index > lastMatch) lastMatch = index;

      if (matchStart)
         {
         newStart = trimmed;
         matchStart = false;
         }

      if (matchStop)
         {
         newStop = trimmed;
         matchStop = false;
         }
      }

   // If start and stop are not in the reference, adjust them
   // according to information in the target list
   int startIndex = referenceHash.Integer(start);
   int stopIndex = referenceHash.Integer(stop);

   if (startIndex < 0 && !start.IsEmpty())
      {
      if (newStart.IsEmpty()) return;

      start = newStart;
      startIndex = referenceHash.Integer(start);
      }
   firstMatch = firstMatch < startIndex ? firstMatch : startIndex;

   if (stopIndex < 0 && !stop.IsEmpty())
      {
      if (newStop.IsEmpty()) return;

      stop = newStop;
      stopIndex = referenceHash.Integer(stop);
      }
   lastMatch = lastMatch > stopIndex ? lastMatch : stopIndex;

   int clipFrom = !start.IsEmpty() ? firstMatch : 0;
   int clipTo = !stop.IsEmpty() ? lastMatch : reference.markerCount - 1;

   if (clipFrom > 0 || clipTo < reference.markerCount - 1)
      {
      printf("  Clipping reference haplotypes to match target ...\n");

      reference.ClipHaplotypes(clipFrom, clipTo);

      StringArray newMarkerList;
      newMarkerList.Dimension(reference.markerCount);
      for (int i = clipFrom; i <= clipTo; i++)
         newMarkerList[i - clipFrom].Swap(refMarkerList[i]);
      newMarkerList.Swap(refMarkerList);

      referenceHash.Clear();
      for (int i = 0; i < refMarkerList.Length(); i++)
         referenceHash.Add(refMarkerList[i].Trim(), i);

      printf("    %d Markers Remain After Clipping ...\n", reference.markerCount);
      }
   }
开发者ID:cfuchsberger,项目名称:minimac,代码行数:93,代码来源:HaplotypeClipper.cpp


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