Exemple #1
0
void SAXSapHandler::startElement(const XML_Char *el, const XML_Char **attr)
{
    if(isElement("protein", el)) {
        m_bProtein = true;
        m_mapItem.clear();
        m_strId = getAttrValue("id", attr);
    }
    else if(isElement("aa", el)) {
        char res = '\0';
        char mut = '\0';
        m_bAa = true;
        string strValue;
        strValue = getAttrValue("at",attr);
        m_pairItem.first = atoi(strValue.c_str());
        strValue = getAttrValue("mut",attr);
        m_pairItem.second.first = strValue[0];
        mut = strValue[0];
        m_pairItem.second.second = getAttrValue("id",attr);
        strValue = getAttrValue("type",attr);
        res = strValue[0];
        if(checkMut(res,mut))	{
            m_mapItem.insert(m_pairItem);
        }
    }
}
void SAXMzxmlHandler::startElement(const XML_Char *el, const XML_Char **attr)
{
	if(isElement("scan", el))
	{
		if((m_cidLevel = atoi(getAttrValue("msLevel", attr))) == 2)
		{
			m_bInMsLevel2 = true;

			reset();	// Clean up for the next scan

			m_scanNum = atoi(getAttrValue("num", attr));
			m_tId = m_scanNum;
			while(m_sId.find(m_tId) != m_sId.end())	{
				m_tId++;
			}
			m_sId.insert(m_tId);
			m_peaksCount = atoi(getAttrValue("peaksCount", attr));
		}
	}
	else if(isElement("peaks", el))
	{
		m_bInPeaks = true;
		m_bLowPrecision = (strcmp("64", getAttrValue("precision", attr)) != 0);
	}
	else if(isElement("precursorMz", el))
	{
		m_bInPrecursorMz = true;
		m_precursorCharge = atoi(getAttrValue("precursorCharge", attr));
	}
}
Exemple #3
0
//----------------------------------------------------------------
void GraphView::addEdges(Iterator<edge> *addedEdges) {
  std::vector<edge> ee;
  std::vector<edge> superEdges;
  Graph *super = getSuperGraph();
  bool superIsRoot = (super == getRoot());

  while (addedEdges->hasNext()) {
    edge e = addedEdges->next();
    assert(getRootImpl()->isElement(e));
    assert(isElement(source(e)));
    assert(isElement(target(e)));

    if (!isElement(e)) {
      ee.push_back(e);

      if (!superIsRoot && !super->isElement(e))
        superEdges.push_back(e);
    }
  }

  if (!superEdges.empty()) {
    StlIterator<edge, std::vector<edge>::iterator> it(superEdges.begin(), superEdges.end());
    super->addEdges(&it);
  }

  if (!ee.empty())
    addEdgesInternal(ee.size(), &ee, std::vector<pair<node, node>>());
}
Exemple #4
0
//----------------------------------------------------------------
std::vector<edge> GraphView::getEdges(const node src, const node tgt, bool directed) const {
  std::vector<edge> ee;

  if (isElement(src) && isElement(tgt))
    getRootImpl()->getEdges(src, tgt, directed, ee, this);

  return ee;
}
Exemple #5
0
//----------------------------------------------------------------
edge GraphView::existEdge(const node src, const node tgt, bool directed) const {
  if (!isElement(src) || !isElement(tgt))
    return edge();

  std::vector<edge> ee;

  return getRootImpl()->getEdges(src, tgt, directed, ee, this, true) ? ee[0] : edge();
}
Exemple #6
0
//----------------------------------------------------------------
void GraphView::addEdge(const edge e) {
  assert(getRootImpl()->isElement(e));
  assert(isElement(source(e)));
  assert(isElement(target(e)));

  if (!isElement(e)) {
    if (!getSuperGraph()->isElement(e))
      getSuperGraph()->addEdge(e);

    addEdgeInternal(e);
  }
}
bool Theme::checkThemeVersion(){
	debug_out("bool checkThemeVersion()");
    bool text = false;
    bool title =false;
    bool inactive =false;
    bool isNewTheme=false;
    if (isElement("WindowStyle","Active","Text")){text=true;}
    if (isElement("WindowStyle","Active","Title")){title=true;}
    if (isElement("WindowStyle","Inactive")){inactive=true;}
    if(text || title || inactive){ isNewTheme=false;}
    else{isNewTheme=true;}
    return isNewTheme;
}
void SAXBiomlHandler::endElement(const XML_Char *el)
{
	if(isElement("protein", el)){
		m_bProtein = false;
		if(m_setSeq.find(m_seqCurrent.m_tUid) == m_setSeq.end())	{
			m_vseqBest.push_back(m_seqCurrent);
			m_setSeq.insert(m_seqCurrent.m_tUid);
		}
	}
	else if(isElement("peptide", el)){
		m_bPeptide = false;
	}
}
Exemple #9
0
//----------------------------------------------------------------
void GraphView::setEndsInternal(const edge e, node src, node tgt, const node newSrc,
                                const node newTgt) {
  if (isElement(e)) {
    if (isElement(newSrc) && isElement(newTgt)) {
      notifyBeforeSetEnds(e);

      if (src != newSrc) {
        _nodeData.get(newSrc.id)->outDegreeAdd(1);

        if (src.isValid() && isElement(src))
          _nodeData.get(src.id)->outDegreeAdd(-1);
        else
          // as src may no longer exist (pop case)
          // set src as invalid for subgraphs loop
          src = node();
      }

      if (tgt != newTgt) {
        _nodeData.get(newTgt.id)->inDegreeAdd(1);

        if (tgt.isValid() && isElement(tgt))
          _nodeData.get(tgt.id)->inDegreeAdd(-1);
        else
          // as tgt may no longer exist (pop case)
          // set tgt as invalid for subgraphs loop
          tgt = node();
      }

      // notification
      notifyAfterSetEnds(e);

      // propagate edge ends update on subgraphs
      for (Graph *sg : subGraphs()) {
        static_cast<GraphView *>(sg)->setEndsInternal(e, src, tgt, newSrc, newTgt);
      }
    } else {
      // delete e if its new ends do no belong to the graph
      // propagate edge ends update on subgraphs
      for (Graph *sg : subGraphs()) {
        static_cast<GraphView *>(sg)->setEndsInternal(e, src, tgt, newSrc, newTgt);
      }
      notifyDelEdge(e);

      _edges.remove(e);
      propertyContainer->erase(e);
      _nodeData.get(src.id)->outDegreeAdd(-1);
      _nodeData.get(tgt.id)->inDegreeAdd(-1);
    }
  }
}
Exemple #10
0
void SAXMzxmlHandler::endElement(const XML_Char *el)
{
	if(isElement("peaks", el))
	{
		processData();
		m_bInPeaks = false;
	}
	else if(isElement("precursorMz", el))
	{
		processData();
		m_bInPrecursorMz = false;
	}
	else if(isElement("scan", el) && m_bInMsLevel2 == true)
	{
		// only add a spectrum without charge (which will lead
		// to internal xtandem charge state guessing) if there
		// were no values parsed from *both* "precursorCharge"
		// or "possibleCharges"
		if ( (m_precursorCharge == 0) && (m_viPossiblePrecursorCharges.size() == 0) ) {
		  // add spectrum, with precursorMz charge
		  pushSpectrum();
		}
		
		else {

		  // add the spectrum with the m_precursorCharge value
		  int originalPrecursorMZ = m_precursorCharge; // do other pushSpectrum calls change this?
		  pushSpectrum(m_precursorCharge);
		  
		  // are there any multiple precursor charges from mzXML 3.1's
		  // possibleCharges?
		  if (m_viPossiblePrecursorCharges.size() > 0) {
		    size_t originalId = m_tId;
		    for (vector<int>::iterator i = m_viPossiblePrecursorCharges.begin();
			 i != m_viPossiblePrecursorCharges.end();
			 ++i) {
		      int z = *i;
		      if (z != originalPrecursorMZ) { // no need to duplicate if already added
			m_tId += 100000000;
			pushSpectrum(z);
		      }
		    }
		    m_tId = originalId;
		  }
		}

		m_bInMsLevel2 = false;
	}
}
Exemple #11
0
//----------------------------------------------------------------
void GraphView::removeNode(const node n) {
  assert(isElement(n));
  notifyDelNode(n);
  _nodeData.set(n.id, nullptr);
  _nodes.remove(n);
  propertyContainer->erase(n);
}
Exemple #12
0
   xml_node* xml_node::create( string const& temp ) {
      if( temp.size() < 2 ) { // only <> in element
         throw Xml_exception(
            eEx::parse, msg_unknown_node + ": " + temp );
         //         return 0;
      }

      xml_document* d = document();
      assert( d != nullptr );

      if( isElement( temp ) ) {  // is alpha or underscore
         xml_node* node =  d->element_create();
         return node;
      }

      if( isComment( temp ) ) {  // <!-- und -->
         xml_node* node = d->comment_create();
         return node;
      }

      if( isDeclaration( temp ) )  {   // "<?xml und ?>"
         xml_node* node = d->declaration_create( tlfm_ );
         return node;
      }

      throw Xml_exception(
         eEx::parse, msg_unknown_node + ": " + temp );
   }
Exemple #13
0
void DocumentBuilder::consumeContent(Node *root){
  while(peek() != -1){
    consumeText(root);
    if (isElement()){
      consumeElement(root);
      continue;
    }
    if (isComment()){
      consumeComment(root);
      continue;
    }
    if (isCDataSection()){
      consumeCDataSection(root);
      continue;
    }
    if(isPI()){
      consumePI(root);
      continue;
    }
    if (isCharRef()){
      StringBuffer *sb = new StringBuffer(2);
      sb->append(consumeCharRef());
      appendToLastTextNode(root, sb);
      continue;
    }
    if (isEntityRef()){
      String *entext = consumeEntityRef(true);
      appendToLastTextNode(root, entext);
      continue;
    }
    if (peek(0) == '<') break;
  };
}
Exemple #14
0
//----------------------------------------------------------------
void GraphView::addNodes(Iterator<node> *addedNodes) {
  std::vector<node> nodes;
  std::vector<node> superNodes;
  Graph *super = getSuperGraph();
  bool superIsRoot = (super == getRoot());

  while (addedNodes->hasNext()) {
    node n = addedNodes->next();

    if (!isElement(n)) {
      nodes.push_back(n);

      if (!superIsRoot && !super->isElement(n))
        superNodes.push_back(n);
    }
  }

  if (!superNodes.empty()) {
    StlIterator<node, std::vector<node>::iterator> it(superNodes.begin(), superNodes.end());
    super->addNodes(&it);
  }

  if (!nodes.empty())
    addNodesInternal(nodes.size(), &nodes);
}
Exemple #15
0
void SAXTaxHandler::startElement(const XML_Char *el, const XML_Char **attr)
{
	const char* label = getAttrValue("label", attr);
	if(isElement("taxon", el) && m_setTax.find(label) != m_setTax.end()){
		m_bTax = true;
	}
	else if(isElement("file", el) && m_bTax){
		string strType = getAttrValue("format",attr);
		if(m_strType == strType)	{
			string strPath = getAttrValue("URL",attr);
			if(m_setPaths.find(strPath) == m_setPaths.end())	{
				m_vstrPaths->push_back(strPath);
				m_setPaths.insert(strPath);
			}
		}
	}
}
void SAXMzdataHandler::endElement(const XML_Char *el)
{
	if(isElement("mzArrayBinary", el))
		m_bInmzArrayBinary = false;
	else if(isElement("intenArrayBinary", el))
		m_bInintenArrayBinary = false;
	else if(isElement("data", el))
	{
		processData();
		m_bInData = false;
	}
	else if(isElement("spectrum", el) && m_bInMsLevel2)
	{
		pushSpectrum();
		m_bInMsLevel2 = false;
	}
}
Exemple #17
0
void SAXMzmlHandler::endElement(const XML_Char *el)
{
	if(isElement("binary", el))	{
		processData();
		m_bInintenArrayBinary = false;
		m_bInmzArrayBinary = false;
		m_bInData = false;
	}
	else if(isElement("spectrum", el) && m_bInMsLevel2)
	{
		pushSpectrum();
		m_bInMsLevel2 = false;
	}
	else if (isElement("referenceableParamGroup", el))
	{
		m_bInRefGroup = false;
	}
}
Exemple #18
0
void Tree::dropCurrentElement(Vertex *v)
{
    sabassert(stackTop && isElement(stackTop));
    sabassert(stackTop == v);
    sabassert(!pendingTextNode);
    stackTop = v -> parent;
    delete v;
    toE(stackTop) -> contents.deppend();
}
void SAXMzxmlHandler::endElement(const XML_Char *el)
{
	if(isElement("peaks", el))
	{
		processData();
		m_bInPeaks = false;
	}
	else if(isElement("precursorMz", el))
	{
		processData();
		m_bInPrecursorMz = false;
	}
	else if(isElement("scan", el) && m_bInMsLevel2 == true)
	{
		pushSpectrum();
		m_bInMsLevel2 = false;
	}
}
Exemple #20
0
void Set::print(ostream& out) const
{
    out << "[Set (" << m_size << ") ";

    for (int i=0; i<m_size; i++) {
        out << (bool) isElement(i) << " ";
    }
    out << "]";
}
char huffdecoditication::getElementTree(cell* node,QString HuffmanCodification)
{
    char charReturn;
    if(node->leaf != true)
    {
        if(HuffmanCodification.at(0).toLatin1()=='0')
        {
            charReturn=isElement(node->left, HuffmanCodification.remove(0,1));
        }
        if(HuffmanCodification.at(0).toLatin1()=='1')
        {
            charReturn=isElement(node->right,HuffmanCodification.remove(0,1));
        }
    }
    if(node->leaf)
    {
        return node->getElement();
    }
}
int hasElement(binTree *root, int cur)
{
    if (root == NULL)
    {
        return 0;
    }
    if (root->value < cur)
    {
        isElement(root->right, cur);
    }
    else if (root->value > cur)
    {
        isElement(root->left, cur);
    }
    else if (root->value == cur)
    {
        return 1;
    }
}
Exemple #23
0
//----------------------------------------------------------------
void GraphView::addNode(const node n) {
  assert(getRoot()->isElement(n));

  if (!isElement(n)) {
    if (!getSuperGraph()->isElement(n))
      getSuperGraph()->addNode(n);

    restoreNode(n);
  }
}
Exemple #24
0
int main()
{ 
    char * x;
    char tab[ROZMIAR];
    printf (" wpisz tekst:\n");    
    fgets(tab, ROZMIAR, stdin);
    x=isElement(tab, 'a');
    printf("%d\n", x);      
    system("pause");
  }
Exemple #25
0
ostream& ppsig::printrec (ostream& fout, Tree var, Tree lexp, bool hide) const
{
    if (isElement(var, fEnv) ) {
        fout << *var;
    } else if (hide) {
        fout << *var;
    } else {
        fout << "letrec(" << *var << " = " << ppsig(lexp, addElement(var, fEnv)) << ")";
    }
    return fout;
}
//Adds user specified int to set if it isn't already an element.
void Set::add(const int add){
  if(!isElement(add)){
    if(!_cardinality==0){
      if((_cardinality)%(_chunk_size)==0){
      _grow();
      }
    }
    _element[_cardinality] = add;
    _cardinality++;
  }
}
Exemple #27
0
NodeID Set::smallestElement() const
{
    assert(count() > 0);
    int counter = 0;
    for (int i=0; i<m_size; i++) {
        if (isElement(i)) {
            return i;
        }
    }
    ERROR_MSG("No smallest element of an empty set.");
}
Exemple #28
0
void SAXGamlHandler::endElement(const XML_Char *el)
{
	if(isElement("note", el) && m_bDesc){
		m_bDesc=false;
	}
	else if(isElement("GAML:Xdata", el) && m_bInData){
		pushPeaks(m_bMZ, m_bINT);
		m_strData.clear();
		m_bMZ = false;
	}
	else if(isElement("GAML:Ydata", el) && m_bInData){
		pushPeaks(m_bMZ, m_bINT);
		m_strData.clear();
		m_bINT = false;
	}
	else if(isElement("GAML:trace", el) && m_bInData){
		pushSpectrum();
		reset();
		m_bInData=false;
	}
}
bool Mandelbrot::calculate()
{
	// Calculate step size
	double step_x = (max_x - min_x) / (double) width;
	double step_y = (max_y - min_y) / (double) height;

	if(step_x == 0.0 || step_y == 0.0)
	{
		m_last_error = "Mandelbrot: step_x or step_y is 0";
		return true;
	}

	// Create image
	if(create(width, height))
		return true;

	// Allocate colors
	if(allocateColors())
		return true;

	// Real calculation
	bool do_break = false;
	for(int x = 0; x < width; x++)
	{
		for(int y = 0; y < height; y++)
		{
			if(update())
			{
				do_break = true;
				break;
			}

			// Calculation for current complex number
			Complex c(min_x + step_x * x, max_y - step_y * y);
			int number;

			bool state = isElement(&c, &number);

			// Get color and set pixel
			int red, green, blue;
			getColor(state, number, &red, &green, &blue);
			setPixel(x, y, red, green, blue);
		}

		if(do_break)
			break;
	}

	// Free colors
	freeColors();	

	return false;
}
Exemple #30
0
//----------------------------------------------------------------
void GraphView::removeEdge(const edge e) {
  assert(isElement(e));
  notifyDelEdge(e);

  _edges.remove(e);
  propertyContainer->erase(e);
  const std::pair<node, node> &eEnds = ends(e);
  node src = eEnds.first;
  node tgt = eEnds.second;
  _nodeData.get(src.id)->outDegreeAdd(-1);
  _nodeData.get(tgt.id)->inDegreeAdd(-1);
}