Example #1
0
 //reimplemented in order to remove the "indexmzML" tag from the front (if present)
 String MzMLValidator::getPath_(UInt remove_from_end) const
 {
   String path;
   if (open_tags_.size() != 0 && open_tags_.front() == "indexedmzML")
   {
     path.concatenate(open_tags_.begin() + 1, open_tags_.end() - remove_from_end, "/");
   }
   else
   {
     path.concatenate(open_tags_.begin(), open_tags_.end() - remove_from_end, "/");
   }
   path = String("/") + path;
   return path;
 }
  void ConsensusIDAlgorithmIdentity::preprocess_(
    vector<PeptideIdentification>& ids)
  {
    // check score types and orientations:
    bool higher_better = ids[0].isHigherScoreBetter();
    set<String> score_types;

    for (vector<PeptideIdentification>::iterator pep_it = ids.begin();
         pep_it != ids.end(); ++pep_it)
    {
      if (pep_it->isHigherScoreBetter() != higher_better)
      {
        // scores with different orientations definitely aren't comparable:
        String hi_lo = higher_better ? "higher/lower" : "lower/higher";
        String msg = "Score types '" + ids[0].getScoreType() + "' and '" +
          pep_it->getScoreType() + "' have different orientations (" + hi_lo +
          " is better) and cannot be compared meaningfully.";
        throw Exception::InvalidValue(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION,
                                      msg, higher_better ? "false" : "true");
      }
      score_types.insert(pep_it->getScoreType());
    }

    if (score_types.size() > 1)
    {
      String types;
      types.concatenate(score_types.begin(), score_types.end(), "'/'");
      LOG_WARN << "Warning: Different score types for peptide hits found ('"
               << types << "'). If the scores are not comparable, "
               << "results will be meaningless." << endl;
    }
  }
Example #3
0
 void CsvFile::addRow(const StringList& list)
 {
   StringList elements = list;
   if (itemenclosed_)
   {
     for (Size i = 0; i < elements.size(); ++i)
     {
       elements[i].quote('"', String::NONE);
     }
   }
   String line;
   line.concatenate(elements.begin(), elements.end(), itemseperator_);
   addLine(line);
 }
  explicit HeaderInfo(const String& filename)
  {
    header_description = "-- empty --";
    TextFile tf;
    tf.load(filename);
    String content;
    content.concatenate(tf.begin(), tf.end(), ";");

    String search = "$$ Sample Description:";
    Size pos = content.find(search);
    if (pos != std::string::npos)
    {
      pos += search.size();
      Size pos_end = content.find("$$", pos);
      if (pos_end != std::string::npos)
      {
        String tmp = content.substr(pos, pos_end - pos - 1);
        if (!tmp.trim().empty()) header_description = tmp;
        //std::cerr << "Header info is: " << header_description << std::endl;
      }
    }
  }
Example #5
0
  //reimplemented in order to handle index MzML
  bool MzMLFile::isValid(const String& filename, std::ostream& os)
  {
    //determine if this is indexed mzML or not
    bool indexed = false;
    TextFile file(filename, true, 4);
    String s;
    s.concatenate(file.begin(), file.end());
    if (s.hasSubstring("<indexedmzML"))
    {
      indexed = true;
    }
    // find the corresponding schema
    String current_location;
    if (indexed)
    {
      current_location = File::find(indexed_schema_location_);
    }
    else
    {
      current_location = File::find(schema_location_);
    }

    return XMLValidator().isValid(filename, current_location, os);
  }