Пример #1
0
Variant f_range(CVarRef low, CVarRef high, CVarRef step /* = 1 */) {
  bool is_step_double = false;
  double dstep = 1.0;
  if (step.isDouble()) {
    dstep = step.toDouble();
    is_step_double = true;
  } else if (step.isString()) {
    int64_t sn;
    double sd;
    DataType stype = step.toString()->isNumericWithVal(sn, sd, 0);
    if (stype == KindOfDouble) {
      is_step_double = true;
      dstep = sd;
    } else if (stype == KindOfInt64) {
      dstep = (double)sn;
    } else {
      dstep = step.toDouble();
    }
  } else {
    dstep = step.toDouble();
  }
  /* We only want positive step values. */
  if (dstep < 0.0) dstep *= -1;
  if (low.isString() && high.isString()) {
    String slow = low.toString();
    String shigh = high.toString();
    if (slow.size() >= 1 && shigh.size() >=1) {
      int64_t n1, n2;
      double d1, d2;
      DataType type1 = slow->isNumericWithVal(n1, d1, 0);
      DataType type2 = shigh->isNumericWithVal(n2, d2, 0);
      if (type1 == KindOfDouble || type2 == KindOfDouble || is_step_double) {
        if (type1 != KindOfDouble) d1 = slow.toDouble();
        if (type2 != KindOfDouble) d2 = shigh.toDouble();
        return ArrayUtil::Range(d1, d2, dstep);
      }

      int64_t lstep = (int64_t) dstep;
      if (type1 == KindOfInt64 || type2 == KindOfInt64) {
        if (type1 != KindOfInt64) n1 = slow.toInt64();
        if (type2 != KindOfInt64) n2 = shigh.toInt64();
        return ArrayUtil::Range((double)n1, (double)n2, lstep);
      }

      return ArrayUtil::Range((unsigned char)slow.charAt(0),
                              (unsigned char)shigh.charAt(0), lstep);
    }
  }

  if (low.is(KindOfDouble) || high.is(KindOfDouble) || is_step_double) {
    return ArrayUtil::Range(low.toDouble(), high.toDouble(), dstep);
  }

  int64_t lstep = (int64_t) dstep;
  return ArrayUtil::Range(low.toDouble(), high.toDouble(), lstep);
}
double AccessibilityUIElement::intValue() const
{
    if (!ATK_IS_OBJECT(m_element.get()))
        return 0;

    if (ATK_IS_VALUE(m_element.get())) {
        GValue value = G_VALUE_INIT;
        atk_value_get_current_value(ATK_VALUE(m_element.get()), &value);
        if (!G_VALUE_HOLDS_FLOAT(&value))
            return 0;
        return g_value_get_float(&value);
    }

    // Consider headings as an special case when returning the "int value" of
    // an AccessibilityUIElement, so we can reuse some tests to check the level
    // both for HTML headings and objects with the aria-level attribute.
    if (atk_object_get_role(ATK_OBJECT(m_element.get())) == ATK_ROLE_HEADING) {
        String headingLevel = getAttributeSetValueForId(ATK_OBJECT(m_element.get()), ObjectAttributeType, "level");
        bool ok;
        double headingLevelValue = headingLevel.toDouble(&ok);
        if (ok)
            return headingLevelValue;
    }

    return 0;
}
Пример #3
0
double parseToDoubleForNumberType(const String& string, double fallbackValue)
{
    // See HTML5 2.5.4.3 `Real numbers.'

    // String::toDouble() accepts leading + and whitespace characters, which are not valid here.
    UChar firstCharacter = string[0];
    if (firstCharacter != '-' && firstCharacter != '.' && !isASCIIDigit(firstCharacter))
        return fallbackValue;

    bool valid = false;
    double value = string.toDouble(&valid);
    if (!valid)
        return fallbackValue;

    // NaN and infinity are considered valid by String::toDouble, but not valid here.
    if (!std::isfinite(value))
        return fallbackValue;

    // Numbers are considered finite IEEE 754 single-precision floating point values.
    // See HTML5 2.5.4.3 `Real numbers.'
    if (-std::numeric_limits<float>::max() > value || value > std::numeric_limits<float>::max())
        return fallbackValue;

    // The following expression converts -0 to +0.
    return value ? value : 0;
}
bool parseToDoubleForNumberType(const String& string, double* result)
{
    // See HTML5 2.4.4.3 `Real numbers.'

    // String::toDouble() accepts leading + and whitespace characters, which are not valid here.
    UChar firstCharacter = string[0];
    if (firstCharacter != '-' && !isASCIIDigit(firstCharacter))
        return false;

    bool valid = false;
    double value = string.toDouble(&valid);
    if (!valid)
        return false;

    // NaN and infinity are considered valid by String::toDouble, but not valid here.
    if (!isfinite(value))
        return false;

    if (result) {
        // The following expression converts -0 to +0.
        *result = value ? value : 0;
    }

    return true;
}
Пример #5
0
static void parseKeySplines(const String &parse, Vector<UnitBezier> &result)
{
    result.clear();
    Vector<String> parseList;
    parse.split(';', parseList);
    for (unsigned n = 0; n < parseList.size(); ++n) {
        Vector<String> parseSpline;
        parseList[n].split(',', parseSpline);
        // The spec says the sepator is a space, all tests use commas. Weird.
        if (parseSpline.size() == 1) {
            parseList[n].split(' ', parseSpline);
        }
        if (parseSpline.size() != 4) {
            goto fail;
        }
        double curveValues[4];
        for (unsigned i = 0; i < 4; ++i) {
            String parseNumber = parseSpline[i];
            bool ok;
            curveValues[i] = parseNumber.toDouble(&ok);
            if (!ok || curveValues[i] < 0.0 || curveValues[i] > 1.0) {
                goto fail;
            }
        }
        result.append(UnitBezier(curveValues[0], curveValues[1], curveValues[2], curveValues[3]));
    }
    return;
fail:
    result.clear();
}
bool parseToDoubleForNumberType(const String& string, double* result)
{
    // See HTML5 2.4.4.3 `Real numbers.'
    
    // String::toDouble() accepts leading + and whitespace characters, which are not valid here.
   // UChar firstCharacter = string[0]; Ricardo: comentando para poner lo sig
    char string1[] = "";
    UChar firstCharacter = string1[0];
    if (firstCharacter != '-' && !isASCIIDigit(firstCharacter))
        return false;

    bool valid = false;
    double value = string.toDouble(&valid);
    if (!valid)
        return false;

    // NaN and infinity are considered valid by String::toDouble, but not valid here.
    if (!isfinite(value))
        return false;

    // Numbers are considered finite IEEE 754 single-precision floating point values.
    // See HTML5 2.4.4.3 `Real numbers.'
    if (-std::numeric_limits<float>::max() > value || value > std::numeric_limits<float>::max())
        return false;

    if (result) {
        // The following expression converts -0 to +0.
        *result = value ? value : 0;
    }

    return true;
}
Пример #7
0
double SliderRange::valueFromElement(HTMLInputElement* element, bool* wasClamped)
{
    String valueString = element->value();
    double oldValue = valueString.isNull() ? (minimum + maximum) / 2 : valueString.toDouble();
    double newValue = clampValue(oldValue);

    if (wasClamped)
        *wasClamped = valueString.isNull() || newValue != oldValue;

    return newValue;
}
TextureMapperFPSCounter::TextureMapperFPSCounter()
    : m_isShowingFPS(false)
    , m_fpsInterval(0)
    , m_fpsTimestamp(0)
    , m_lastFPS(0)
    , m_frameCount(0)
{
    String showFPSEnvironment = getenv("WEBKIT_SHOW_FPS");
    bool ok = false;
    m_fpsInterval = showFPSEnvironment.toDouble(&ok);
    if (ok && m_fpsInterval) {
        m_isShowingFPS = true;
        m_fpsTimestamp = WTF::currentTime();
    }
}
Пример #9
0
void Cookie::setMaxAge(const String& maxAge)
{
    bool ok;
    m_expiry = maxAge.toDouble(&ok);
    if (!ok) {
        LOG_ERROR("Could not parse Max-Age : %s", maxAge.ascii().data());
        return;
    }

    m_isSession = false;

    // If maxAge is null, keep the value so that it is discarded later.
    // FIXME: is this necessary?
    if (m_expiry)
        m_expiry += currentTime();
}
Пример #10
0
std::optional<std::chrono::microseconds> ResourceResponseBase::age() const
{
    using namespace std::chrono;

    lazyInit(CommonFieldsOnly);

    if (!m_haveParsedAgeHeader) {
        String headerValue = m_httpHeaderFields.get(HTTPHeaderName::Age);
        bool ok;
        double ageDouble = headerValue.toDouble(&ok);
        if (ok)
            m_age = duration_cast<microseconds>(duration<double>(ageDouble));
        m_haveParsedAgeHeader = true;
    }
    return m_age;
}
Пример #11
0
SMILTime SVGSMILElement::parseOffsetValue(const String& data) {
  bool ok;
  double result = 0;
  String parse = data.stripWhiteSpace();
  if (parse.endsWith('h'))
    result = parse.left(parse.length() - 1).toDouble(&ok) * 60 * 60;
  else if (parse.endsWith("min"))
    result = parse.left(parse.length() - 3).toDouble(&ok) * 60;
  else if (parse.endsWith("ms"))
    result = parse.left(parse.length() - 2).toDouble(&ok) / 1000;
  else if (parse.endsWith('s'))
    result = parse.left(parse.length() - 1).toDouble(&ok);
  else
    result = parse.toDouble(&ok);
  if (!ok || !SMILTime(result).isFinite())
    return SMILTime::unresolved();
  return result;
}
Пример #12
0
 void MzTabDouble::fromCellString(const String& s)
 {
   String lower = s;
   lower.toLower().trim();
   if (lower == "null")
   {
     setNull(true);
   }
   else if (lower == "nan")
   {
     setNaN();
   }
   else if (lower == "inf")
   {
     setInf();
   }
   else // default case
   {
     set(lower.toDouble());
   }
 }
Пример #13
0
double parseToDoubleForNumberType(const String& string, double fallbackValue)
{
    // http://www.whatwg.org/specs/web-apps/current-work/#floating-point-numbers
    // String::toDouble() accepts leading + and whitespace characters, which are not valid here.
    UChar firstCharacter = string[0];
    if (firstCharacter != '-' && firstCharacter != '.' && !isASCIIDigit(firstCharacter))
        return fallbackValue;

    bool valid = false;
    double value = string.toDouble(&valid);
    if (!valid)
        return fallbackValue;

    // NaN and infinity are considered valid by String::toDouble, but not valid here.
    if (!std::isfinite(value))
        return fallbackValue;

    // Numbers are considered finite IEEE 754 Double-precision floating point values.
    if (-std::numeric_limits<double>::max() > value || value > std::numeric_limits<double>::max())
        return fallbackValue;

    // The following expression converts -0 to +0.
    return value ? value : 0;
}
Пример #14
0
double RenderSlider::setPositionFromValue(bool inLayout)
{
    if (!m_thumb || !m_thumb->renderer())
        return 0;
    
    if (!inLayout)
        document()->updateLayout();
        
    String value = static_cast<HTMLInputElement*>(node())->value();
    const AtomicString& minStr = static_cast<HTMLInputElement*>(node())->getAttribute(minAttr);
    const AtomicString& maxStr = static_cast<HTMLInputElement*>(node())->getAttribute(maxAttr);
    const AtomicString& precision = static_cast<HTMLInputElement*>(node())->getAttribute(precisionAttr);
    
    double minVal = minStr.isNull() ? 0.0 : minStr.toDouble();
    double maxVal = maxStr.isNull() ? 100.0 : maxStr.toDouble();
    minVal = min(minVal, maxVal); // Make sure the range is sane.
    
    double oldVal = value.isNull() ? (maxVal + minVal)/2.0 : value.toDouble();
    double val = max(minVal, min(oldVal, maxVal)); // Make sure val is within min/max.
        
    // Force integer value if not float.
    if (!equalIgnoringCase(precision, "float"))
        val = lround(val);

    // Calculate the new position based on the value
    double factor = (val - minVal) / (maxVal - minVal);
    if (style()->appearance() == SliderVerticalAppearance)
        factor = 1.0 - factor;

    setCurrentPosition((int)(factor * trackSize()));
    
    if (value.isNull() || val != oldVal)
        static_cast<HTMLInputElement*>(node())->setValueFromRenderer(String::number(val));
    
    return val;
}
Пример #15
0
int main(int argc, char* argv[])
{
	CommandlineParser parpars("DockResultMerger", "merge docking output files", VERSION, String(__DATE__), "Convert, combine and store");
	parpars.registerMandatoryInputFile("i", "input files");
	parpars.registerMandatoryOutputFile("o", "output file");

	parpars.registerOptionalStringParameter("score", "score property name", "score");
	parpars.registerOptionalDoubleParameter("min", "minimal score value", -30.0);
	parpars.registerOptionalDoubleParameter("max", "maximal score value", 0.0);
	parpars.registerOptionalIntegerParameter("k", "number of output molecules", 20);

	parpars.registerFlag("rm", "remove input files after merging");
	parpars.setSupportedFormats("i","mol2,sdf,drf");
	parpars.setSupportedFormats("o","mol2,sdf,drf");
	String manual = "This tool merges and sorts molecule files as generated by docking or rescoring.\n\nYou need to specify the property-tag name of the scores according to which the molecules should be sorted. Optionally you can filter those compounds that were assigned a score above and/or below specified thresholds. If desired, you can furthermore choose to have only the compounds with the k best scores written to the output file.\n\n Output of DockResultMerger is one molecule containing the molecules found in input-files (that matched all filter criteria, if any), sorted ascendingly according to their scores.";
	parpars.setToolManual(manual);
	parpars.parse(argc, argv);

	string e_property="score";
	double energy_cutoff = 1e100;
	double energy_cuton = -1e100;
	Size best_k = 100000000;

	String output = parpars.get("o");
	String s = parpars.get("score");
	if (s != CommandlineParser::NOT_FOUND) e_property = s;
	s = parpars.get("min");
	if (s != CommandlineParser::NOT_FOUND) energy_cuton = s.toDouble();
	s = parpars.get("max");
	if (s != CommandlineParser::NOT_FOUND) energy_cutoff = s.toDouble();
	s = parpars.get("k");
	if (s != CommandlineParser::NOT_FOUND) best_k = s.toInt();

	const list<String>& n = parpars.getList("i");
	vector<String> names;
	for (list<String>::const_iterator it = n.begin(); it != n.end(); it++)
	{
		names.push_back(*it);
	}

	bool drf_merge = 0;
	if (output.hasSuffix(".drf"))
	{
		for (Size i = 0; i < names.size(); i++)
		{
			if (names[i].hasSuffix(".drf")) drf_merge = 1;
			else if (drf_merge)
			{
				Log.error()<<"[Error:] Using drf and non-drf files together as input is not supported."<<endl;
				return 1;
			}
		}
	}

	if (drf_merge)
	{
		Log.error()<<"[Error:] Using DockingFiles (*.drf) is not possible since this version of DockResultMerger has been compiled without QtXML support."<<endl;
		return 1;
	}

	if (!drf_merge)
	{
		sortMolecules(names, output, best_k, e_property, energy_cutoff, energy_cuton);
	}

	else
	{
		mergeDRFiles(names, output, best_k, e_property, energy_cutoff, energy_cuton);
	}


	if (parpars.has("rm"))
	{
		for (Size i = 0; i < names.size(); i++)
		{
			File::remove(names[i]);
		}
	}

	return 0;
}
//--------------------------------------------------------------------------------------------------
/// Create variant from the specified XML element
///
/// If the passed XML element is not recognized as a variant, an invalid variant will be returned
//--------------------------------------------------------------------------------------------------
cvf::Variant PropertyXmlSerializer::variantFromXmlElement(const XmlElement& xmlVariantElement)
{
    const String elementName = xmlVariantElement.name().toLower();
    const String valueText = xmlVariantElement.valueText();

    if (elementName == "int")
    {
        bool ok = false;
        int val = valueText.toInt(&ok);
        if (ok)
        {
            return Variant(val);
        }
    }
    else if (elementName == "uint")
    {
        bool ok = false;
        uint val = valueText.toUInt(&ok);
        if (ok)
        {
            return Variant(val);
        }
    }
    else if (elementName == "double")
    {
        bool ok = false;
        double val = valueText.toDouble(&ok);
        if (ok)
        {
            return Variant(val);
        }
    }
    else if (elementName == "float")
    {
        bool ok = false;
        float val = valueText.toFloat(&ok);
        if (ok)
        {
            return Variant(val);
        }
    }
    else if (elementName == "bool")
    {
        String valStr = valueText.toLower();
        bool val = (valStr == "true") ? true : false;
        return Variant(val);
    }
    else if (elementName == "vec3d")
    {
        return variantFromVec3dValueText(valueText);
    }
    else if (elementName == "color3f")
    {
        return variantFromColor3fValueText(valueText);
    }
    else if (elementName == "string")
    {
        return Variant(valueText);
    }
    else if (elementName == "array")
    {
        return arrayVariantFromXmlElement(xmlVariantElement);
    }

    return Variant();
}
Пример #17
0
bool MediaFragmentURIParser::parseNPTTime(const LChar* timeString, unsigned length, unsigned& offset, double& time)
{
    enum Mode { minutes, hours };
    Mode mode = minutes;

    if (offset >= length || !isASCIIDigit(timeString[offset]))
        return false;

    // http://www.w3.org/2008/WebVideo/Fragments/WD-media-fragments-spec/#npttimedef
    // Normal Play Time can either be specified as seconds, with an optional
    // fractional part to indicate miliseconds, or as colon-separated hours,
    // minutes and seconds (again with an optional fraction). Minutes and
    // seconds must be specified as exactly two digits, hours and fractional
    // seconds can be any number of digits. The hours, minutes and seconds
    // specification for NPT is a convenience only, it does not signal frame
    // accuracy. The specification of the "npt:" identifier is optional since
    // NPT is the default time scheme. This specification builds on the RTSP
    // specification of NPT RFC 2326.
    //
    // ; defined in RFC 2326
    // npt-sec       = 1*DIGIT [ "." *DIGIT ]                     ; definitions taken
    // npt-hhmmss    = npt-hh ":" npt-mm ":" npt-ss [ "." *DIGIT] ; from RFC 2326
    // npt-mmss      = npt-mm ":" npt-ss [ "." *DIGIT] 
    // npt-hh        =   1*DIGIT     ; any positive number
    // npt-mm        =   2DIGIT      ; 0-59
    // npt-ss        =   2DIGIT      ; 0-59

    String digits1 = collectDigits(timeString, length, offset);
    int value1 = digits1.toInt();
    if (offset >= length || timeString[offset] == ',') {
        time = value1;
        return true;
    }

    double fraction = 0;
    if (timeString[offset] == '.') {
        if (offset == length)
            return true;
        String digits = collectFraction(timeString, length, offset);
        fraction = digits.toDouble();
        time = value1 + fraction;
        return true;
    }
    
    if (digits1.length() < 2)
        return false;
    if (digits1.length() > 2)
        mode = hours;

    // Collect the next sequence of 0-9 after ':'
    if (offset >= length || timeString[offset++] != ':')
        return false;
    if (offset >= length || !isASCIIDigit(timeString[(offset)]))
        return false;
    String digits2 = collectDigits(timeString, length, offset);
    int value2 = digits2.toInt();
    if (digits2.length() != 2)
        return false;

    // Detect whether this timestamp includes hours.
    int value3;
    if (mode == hours || (offset < length && timeString[offset] == ':')) {
        if (offset >= length || timeString[offset++] != ':')
            return false;
        if (offset >= length || !isASCIIDigit(timeString[offset]))
            return false;
        String digits3 = collectDigits(timeString, length, offset);
        if (digits3.length() != 2)
            return false;
        value3 = digits3.toInt();
    } else {
        value3 = value2;
        value2 = value1;
        value1 = 0;
    }

    if (offset < length && timeString[offset] == '.')
        fraction = collectFraction(timeString, length, offset).toDouble();
    
    time = (value1 * secondsPerHour) + (value2 * secondsPerMinute) + value3 + fraction;
    return true;
}
Пример #18
0
  void ElementDB::readFromFile_(const String& file_name)
  {
    String file = File::find(file_name);

    // load elements into param object
    Param param;
    ParamXMLFile paramFile;
    paramFile.load(file, param);

    UInt an(0);
    String name, symbol;

    // determine prefix
    vector<String> split;
    param.begin().getName().split(':', split);
    String prefix("");
    for (Size i = 0; i < split.size() - 1; ++i)
    {
      prefix += split[i] + ":";
    }
    //cout << "first element prefix=" << prefix << endl;

    Map<UInt, double> Z_to_abundancy;
    Map<UInt, double> Z_to_mass;

    for (Param::ParamIterator it = param.begin(); it != param.end(); ++it)
    {
      // new element started?
      if (!it.getName().hasPrefix(prefix))
      {
        // update prefix
        it.getName().split(':', split);
        prefix = "";
        for (Size i = 0; i < split.size() - 1; ++i)
        {
          prefix += split[i] + ":";
        }
        // cout << "new element prefix=" << prefix << endl;

        // Parsing of previous element is finished. Now store data in Element object
        IsotopeDistribution isotopes = parseIsotopeDistribution_(Z_to_abundancy);
        double avg_weight = calculateAvgWeight_(Z_to_abundancy, Z_to_mass);
        double mono_weight = calculateMonoWeight_(Z_to_mass);

        /*
        // print information about elements
        cout << "Name: " << name << " AtomicNumber: " << an << " Symbol: " << symbol << " AvgWeight: " << avg_weight
             << " MonoWeight: " << mono_weight << " NIsotopes: " << isotopes.size() << endl;

        */
        Element* e = new Element(name, symbol, an, avg_weight, mono_weight, isotopes);
        names_[name] = e;
        symbols_[symbol] = e;
        atomic_numbers_[an] = e;

        // add all the individual isotopes as separat elements
        for (IsotopeDistribution::ConstIterator iit = isotopes.begin(); iit != isotopes.end(); ++iit)
        {
          String iso_name = "(" + String(iit->first) + ")" + name;
          String iso_symbol = "(" + String(iit->first) + ")" + symbol;

          // set avg and mono to same value for isotopes (old hack...)
          DoubleReal iso_avg_weight = Z_to_mass[(UInt) iit->first];
          DoubleReal iso_mono_weight = iso_avg_weight;
          IsotopeDistribution iso_isotopes;
          vector<pair<Size, double> > iso_container;
          iso_container.push_back(make_pair(iit->first, 1.0));
          iso_isotopes.set(iso_container);

          /*
          // print name, symbal and atomic mass of the current isotope
          cout << "Isotope Name: " << iso_name << " Symbol: " << iso_symbol << " AtomicMass: " << iso_mono_weight << endl;
          */

          Element* iso_e = new Element(iso_name, iso_symbol, an, iso_avg_weight, iso_mono_weight, iso_isotopes);
          names_[iso_name] = iso_e;
          names_[iso_symbol] = iso_e;
        }

        Z_to_abundancy.clear();
        Z_to_mass.clear();
      }

      // top level: read the contents of the element section
      it.getName().split(':', split);
      String key = split[2];
      String value = it->value;
      value.trim();

      // cout << "Key=" << key << endl;

      if (key == "AtomicNumber")
      {
        an = (UInt)value.toInt();
      }
      else
      {
        if (key == "Isotopes")
        {
          UInt Z = UInt(split[3].toInt());
          String item = split[4];
          if (item == "RelativeAbundance")
          {
            Z_to_abundancy[Z] = double(value.toDouble() / 100.0);
          }
          else if (item == "AtomicMass")
          {
            Z_to_mass[Z] = double(value.toDouble());
          }
          else
          {
            cerr << "read unknown item in Isotopes: " << item << endl;
          }
        }
        else
        {
          if (key == "Name")
          {
            name = value;
          }
          else
          {
            if (key == "Symbol")
            {
              symbol = value;
            }
            else
            {
              cerr << "read unknown tag: " << key << endl;
            }
          }
        }
      }
    }

    // build last element
    double avg_weight(0), mono_weight(0);
    IsotopeDistribution isotopes = parseIsotopeDistribution_(Z_to_abundancy);
    Element* e = new Element(name, symbol, an, avg_weight, mono_weight, isotopes);
    names_[name] = e;
    symbols_[symbol] = e;
    atomic_numbers_[an] = e;
  }
Пример #19
0
	void DockingAlgorithm::readOptionFile(String filename, Options& output_options, list<Constraint*>& output_constraints, const AtomContainer* ref_ligand)
	{
		INIFile ini(filename);
		ini.read();
		Size num_sections = ini.getNumberOfSections();
		for(Size i = 0; i < num_sections; i++)
		{
			String name = ini.getSection(i)->getName();
			if (name.hasPrefix("ReferenceArea") || name.hasPrefix("PharmacophoreConstraint"))
			{
				continue;
			}

			Options* options_category = &output_options;
			if (name != "Docking-Settings")
			{
				options_category = output_options.createSubcategory(name);
			}

			Log.level(10)<<endl<<"--- Reading parameter-section '" << name << "' from file "<<"'"<<filename<<"' :  -----"<<endl;
			INIFile::LineIterator it = ini.getSectionFirstLine(name);
			INIFile::LineIterator it_end = ini.getSectionLastLine(name).getSectionNextLine();
			it.getSectionNextLine();
			for (; it != it_end; it.getSectionNextLine())
			{
				String line = *it;
				if (line == "") continue;
				String key = line.before("="); key.trim();
				String value = line.after("="); value.trim();
				if (key == "" || value == "") continue;
				options_category->set(key, value);

				if (name == ScoringFunction::SUBCATEGORY_NAME || name == "IMGDock")
				{
					Log.level(10)<<key<<" : "<<value<<endl;
				}
			}
		}

		for (Size i = 0; i < 100; i++)
		{
			string sec_name = "ReferenceArea"+String(i);

			if (!ini.hasSection(sec_name)) break;

			Log.level(10)<<endl<<"--- Reading "<<sec_name<<" from file "<<"'"<<filename<<"' :  -----"<<endl;

			String name = ini.getValue(sec_name, "name");
			bool is_fraction = ini.getValue(sec_name, "is_fraction").toBool();
			double penalty = ini.getValue(sec_name, "penalty").toDouble();
			double atoms = ini.getValue(sec_name, "atoms").toDouble();
			vector<Vector3> v(4);

			Log.level(10)<<"name = "<<name<<endl;
			Log.level(10)<<"is_fraction = "<<is_fraction<<endl;
			Log.level(10)<<"atoms = "<<atoms<<endl;
			Log.level(10)<<"penalty = "<<penalty<<endl;
			ReferenceArea* rf;

			String use_ref = ini.getValue(sec_name, "use_ref_ligand");
			if (use_ref != INIFile::UNDEFINED && use_ref.toBool())
			{
				Log.level(10)<<"use_ref_ligand = true"<<endl;
				if (!ref_ligand)
				{
					throw BALL::Exception::GeneralException(__FILE__, __LINE__, "DockingAlgorithm::readOptionFile()", "Reference-ligand required but not specified!");
				}
				rf = new ReferenceArea(ref_ligand, is_fraction, atoms, penalty);
				v = rf->input_points_;
			}
			else
			{
				for (Size i = 0; i <= 3; i++)
				{
					String pn = "p"+String(i);
					String s = ini.getValue(sec_name, pn);
					if (s == INIFile::UNDEFINED)
					{
						Log.error()<<"[Error:] 4 points must be defined for each ReferenceArea!"<<endl;
						return;
					}
					s.trim();
					double d0 = s.getField(0, ", ").toDouble();
					double d1 = s.getField(1, ", ").toDouble();
					double d2 = s.getField(2, ", ").toDouble();
					v[i] = Vector3(d0, d1, d2);
				}
				rf = new ReferenceArea(v[0], v[1], v[2], v[3], is_fraction, atoms, penalty);
			}

			// Increase size of box (e.g. bounding box around ref-ligand), if desired by the user.
			String inc = ini.getValue(sec_name, "box_size_increase");
			if (inc != INIFile::UNDEFINED)
			{
				rf->enlarge(inc.toDouble());
			}

			Log.level(10)<<"p0 = "<<v[0]<<endl;
			Log.level(10)<<"p1 = "<<v[1]<<endl;
			Log.level(10)<<"p2 = "<<v[2]<<endl;
			Log.level(10)<<"p3 = "<<v[3]<<endl;

			if (name != INIFile::UNDEFINED) rf->setName(name);
			output_constraints.push_back(rf);
		}

		for (Size i = 0; i < 100; i++)
		{
			string sec_name = "PharmacophoreConstraint"+String(i);

			if (!ini.hasSection(sec_name)) break;

			Log.level(10)<<endl<<"--- Reading "<<sec_name<<" from file "<<"'"<<filename<<"' :  -----"<<endl;

			String name = ini.getValue(sec_name, "name");
			double penalty = ini.getValue(sec_name, "penalty").toDouble();
			double desired_energy = ini.getValue(sec_name, "desired interaction energy").toDouble();
			String residues = ini.getValue(sec_name, "residue-IDs");
			vector<String> residue_vector;
			residues.split(residue_vector, ", ");
			String types = ini.getValue(sec_name, "interaction types");
			vector<String> types_vector;
			types.split(types_vector, ", ");
			list<String> types_list;
			for (Size i = 0; i < types_vector.size(); i++)
			{
				types_list.push_back(types_vector[i]);
			}

			Log.level(10)<<"name = "<<name<<endl;
			Log.level(10)<<"residue-IDs = "<<residues<<endl;
			Log.level(10)<<"interaction types = "<<types<<endl;
			Log.level(10)<<"desired interaction energy = "<<desired_energy<<endl;
			Log.level(10)<<"penalty = "<<penalty<<endl;

			PharmacophoreConstraint* phc = new PharmacophoreConstraint(residue_vector, types_list, desired_energy, penalty);
			if (name != INIFile::UNDEFINED) phc->setName(name);
			output_constraints.push_back(phc);
		}
		Log.level(10)<<endl<<"--- finished reading config-file."<<endl<<endl<<endl;
	}