コード例 #1
0
ファイル: FeatureMap.cpp プロジェクト: FabianAicheler/OpenMS
  void FeatureMap::updateRanges()
  {
    this->clearRanges();
    updateRanges_(this->begin(), this->end());

    //enlarge the range by the convex hull points
    for (Size i = 0; i < this->size(); ++i)
    {
      DBoundingBox<2> box = this->operator[](i).getConvexHull().getBoundingBox();
      if (!box.isEmpty())
      {
        //update RT
        if (box.minPosition()[Peak2D::RT] < this->pos_range_.minPosition()[Peak2D::RT])
        {
          this->pos_range_.setMinX(box.minPosition()[Peak2D::RT]);
        }
        if (box.maxPosition()[Peak2D::RT] > this->pos_range_.maxPosition()[Peak2D::RT])
        {
          this->pos_range_.setMaxX(box.maxPosition()[Peak2D::RT]);
        }
        //update m/z
        if (box.minPosition()[Peak2D::MZ] < this->pos_range_.minPosition()[Peak2D::MZ])
        {
          this->pos_range_.setMinY(box.minPosition()[Peak2D::MZ]);
        }
        if (box.maxPosition()[Peak2D::MZ] > this->pos_range_.maxPosition()[Peak2D::MZ])
        {
          this->pos_range_.setMaxY(box.maxPosition()[Peak2D::MZ]);
        }
      }
    }
  }
コード例 #2
0
ファイル: IDMapper.C プロジェクト: BioITer/OpenMS
  void IDMapper::increaseBoundingBox_(DBoundingBox<2> & box)
  {
    DPosition<2> sub_min(rt_tolerance_,
                         getAbsoluteMZTolerance_(box.minPosition().getY())),
    add_max(rt_tolerance_, getAbsoluteMZTolerance_(box.maxPosition().getY()));

    box.setMin(box.minPosition() - sub_min);
    box.setMax(box.maxPosition() + add_max);
  }
コード例 #3
0
    bool overlaps_(const Feature& feature, const double rt, const double pc_mz, const double rt_tolerance) const
    {
      if (feature.getConvexHulls().empty())
      {
        LOG_WARN << "HighResPrecursorMassCorrector warning: at least one feature has no convex hull - omitting feature for matching" << std::endl;
      }

      // get bounding box and extend by retention time tolerance
      DBoundingBox<2> box = feature.getConvexHull().getBoundingBox();
      DPosition<2> extend_rt(rt_tolerance, 0.01);
      box.setMin(box.minPosition() - extend_rt);
      box.setMax(box.maxPosition() + extend_rt);

      DPosition<2> pc_pos(rt, pc_mz);
      if (box.encloses(pc_pos))
      {
        return true;
      }
      else
      {
        return false;
      }
    }
コード例 #4
0
  void Spectrum2DWidget::showGoToDialog()
  {
    Spectrum2DGoToDialog goto_dialog(this);
    //set range
    const DRange<2>& area = canvas()->getVisibleArea();
    goto_dialog.setRange(area.minY(), area.maxY(), area.minX(), area.maxX());
    goto_dialog.setMinMaxOfRange(canvas()->getDataRange().minY(), canvas()->getDataRange().maxY(), canvas()->getDataRange().minX(), canvas()->getDataRange().maxX());
    // feature numbers only for consensus&feature maps
    goto_dialog.enableFeatureNumber(canvas()->getCurrentLayer().type == LayerData::DT_FEATURE || canvas()->getCurrentLayer().type == LayerData::DT_CONSENSUS);
    //execute
    if (goto_dialog.exec())
    {
      if (goto_dialog.showRange())
      {
        goto_dialog.fixRange();
        SpectrumCanvas::AreaType area(goto_dialog.getMinMZ(), goto_dialog.getMinRT(), goto_dialog.getMaxMZ(), goto_dialog.getMaxRT());
        if (goto_dialog.clip_checkbox->checkState() == Qt::Checked)
          correctAreaToObeyMinMaxRanges_(area);
        canvas()->setVisibleArea(area);
      }
      else
      {
        String feature_id = goto_dialog.getFeatureNumber();
        //try to convert to UInt64 id
        UniqueIdInterface uid;
        uid.setUniqueId(feature_id);

        Size feature_index(-1); // TODO : not use -1
        if (canvas()->getCurrentLayer().type == LayerData::DT_FEATURE)
          feature_index = canvas()->getCurrentLayer().getFeatureMap()->uniqueIdToIndex(uid.getUniqueId());
        else if (canvas()->getCurrentLayer().type == LayerData::DT_CONSENSUS)
          feature_index = canvas()->getCurrentLayer().getConsensusMap()->uniqueIdToIndex(uid.getUniqueId());
        if (feature_index == Size(-1)) // UID does not exist
        {
          try
          {
            feature_index = feature_id.toInt(); // normal feature index as stored in map
          }
          catch (...) // we might still deal with a UID, so toInt() will throw as the number is too big
          {
            feature_index = Size(-1);
          }
        }

        //check if the feature index exists
        if ((canvas()->getCurrentLayer().type == LayerData::DT_FEATURE && feature_index >= canvas()->getCurrentLayer().getFeatureMap()->size())
           || (canvas()->getCurrentLayer().type == LayerData::DT_CONSENSUS && feature_index >= canvas()->getCurrentLayer().getConsensusMap()->size()))
        {
          QMessageBox::warning(this, "Invalid feature number", "Feature number too large/UniqueID not found.\nPlease select a valid feature!");
          return;
        }
        //display feature with a margin
        if (canvas()->getCurrentLayer().type == LayerData::DT_FEATURE)
        {
          const FeatureMapType& map = *canvas()->getCurrentLayer().getFeatureMap();
          DBoundingBox<2> bb = map[feature_index].getConvexHull().getBoundingBox();
          double rt_margin = (bb.maxPosition()[0] - bb.minPosition()[0]) * 0.5;
          double mz_margin = (bb.maxPosition()[1] - bb.minPosition()[1]) * 2;
          SpectrumCanvas::AreaType narea(bb.minPosition()[1] - mz_margin, bb.minPosition()[0] - rt_margin, bb.maxPosition()[1] + mz_margin, bb.maxPosition()[0] + rt_margin);
          canvas()->setVisibleArea(narea);
        }
        else // Consensus Feature
        {
          const ConsensusFeature& cf = (*canvas()->getCurrentLayer().getConsensusMap())[feature_index];
          double rt_margin = 30;
          double mz_margin = 5;
          SpectrumCanvas::AreaType narea(cf.getMZ() - mz_margin, cf.getRT() - rt_margin, cf.getMZ() + mz_margin, cf.getRT() + rt_margin);
          canvas()->setVisibleArea(narea);
        }

      }
    }
  }
コード例 #5
0
	TEST_REAL_SIMILAR(tmp.getConvexHulls()[0].getHullPoints()[0][1],2.0)
	TEST_REAL_SIMILAR(tmp.getConvexHulls()[0].getHullPoints()[1][0],3.0)
	TEST_REAL_SIMILAR(tmp.getConvexHulls()[0].getHullPoints()[1][1],4.0)
	TEST_REAL_SIMILAR(tmp.getConvexHulls()[1].getHullPoints()[0][0],0.5)
	TEST_REAL_SIMILAR(tmp.getConvexHulls()[1].getHullPoints()[0][1],0.0)
	TEST_REAL_SIMILAR(tmp.getConvexHulls()[1].getHullPoints()[1][0],1.0)
	TEST_REAL_SIMILAR(tmp.getConvexHulls()[1].getHullPoints()[1][1],1.0)
END_SECTION

START_SECTION((ConvexHull2D& getConvexHull() const))
	Feature tmp;
	tmp.setConvexHulls(hulls);

	//check if the bounding box is ok
	DBoundingBox<2> bb = tmp.getConvexHull().getBoundingBox();
	TEST_REAL_SIMILAR(bb.minPosition()[0],0.5)
	TEST_REAL_SIMILAR(bb.minPosition()[1],0.0)
	TEST_REAL_SIMILAR(bb.maxPosition()[0],3.0)
	TEST_REAL_SIMILAR(bb.maxPosition()[1],4.0)

	//check the convex hull points
	TEST_EQUAL(tmp.getConvexHull().getHullPoints().size(),4)
	TEST_REAL_SIMILAR(tmp.getConvexHull().getHullPoints()[0][0],0.5)
	TEST_REAL_SIMILAR(tmp.getConvexHull().getHullPoints()[0][1],0.0)
	TEST_REAL_SIMILAR(tmp.getConvexHull().getHullPoints()[1][0],3.0)
	TEST_REAL_SIMILAR(tmp.getConvexHull().getHullPoints()[1][1],0.0)
	TEST_REAL_SIMILAR(tmp.getConvexHull().getHullPoints()[2][0],3.0)
	TEST_REAL_SIMILAR(tmp.getConvexHull().getHullPoints()[2][1],4.0)
	TEST_REAL_SIMILAR(tmp.getConvexHull().getHullPoints()[3][0],0.5)
	TEST_REAL_SIMILAR(tmp.getConvexHull().getHullPoints()[3][1],4.0)
END_SECTION