Exemple #1
0
TrajectoryFrame
TrajectoryFrameReader::frame()
{
    TrajectoryFrame frame;

    if (!haveProbedForNextFrame_)
    {
        readNextFrame();
    }
    if (!nextFrameExists_)
    {
        GMX_THROW(APIError("There is no next frame, so there should have been no attempt to use the data, e.g. by reacting to a call to readNextFrame()."));
    }

    // Prepare for reading future frames
    haveProbedForNextFrame_ = false;
    nextFrameExists_        = false;

    // The probe filled trxframeGuard_ with new data, so return it
    frame.frame_ = trxframeGuard_.get();

    if (!frame.frame_->bStep)
    {
        GMX_THROW(APIError("Cannot handle trajectory frame that lacks a step number"));
    }

    if (!frame.frame_->bTime)
    {
        GMX_THROW(APIError("Cannot handle trajectory frame that lacks a time"));
    }

    return frame;
}
void SearchController::resultsAction()
{
    checkParams({"id"});

    const int id = params()["id"].toInt();
    int limit = params()["limit"].toInt();
    int offset = params()["offset"].toInt();

    const auto searchHandlers = sessionManager()->session()->getData<SearchHandlerDict>(SEARCH_HANDLERS);
    if (!searchHandlers.contains(id))
        throw APIError(APIErrorType::NotFound);

    const SearchHandlerPtr searchHandler = searchHandlers[id];
    const QList<SearchResult> searchResults = searchHandler->results();
    const int size = searchResults.size();

    if (offset > size)
        throw APIError(APIErrorType::Conflict, tr("Offset is out of range"));

    // normalize values
    if (offset < 0)
        offset = size + offset;
    if (offset < 0)  // check again
        throw APIError(APIErrorType::Conflict, tr("Offset is out of range"));
    if (limit <= 0)
        limit = -1;

    if ((limit > 0) || (offset > 0))
        setResult(getResults(searchResults.mid(offset, limit), searchHandler->isActive(), size));
    else
        setResult(getResults(searchResults, searchHandler->isActive(), size));
}
Exemple #3
0
void
AnalysisDataDisplacementModule::frameStarted(const AnalysisDataFrameHeader &header)
{
    // Initialize times.
    if (_impl->bFirst)
    {
        _impl->t0 = header.x();
    }
    else if (_impl->dt <= 0)
    {
        _impl->dt = header.x() - _impl->t0;
        if (_impl->dt < 0 || gmx_within_tol(_impl->dt, 0.0, GMX_REAL_EPS))
        {
            GMX_THROW(APIError("Identical or decreasing frame times"));
        }
    }
    else
    {
        if (!gmx_within_tol(header.x() - _impl->t, _impl->dt, GMX_REAL_EPS))
        {
            GMX_THROW(APIError("Frames not evenly spaced"));
        }
    }
    _impl->t = header.x();

    // Allocate memory for all the positions once it is possible.
    if (_impl->max_store == -1 && !_impl->bFirst)
    {
        _impl->max_store = _impl->nmax * (int)(_impl->tmax/_impl->dt + 1);
        srenew(_impl->oldval, _impl->max_store);
    }

    // Increment the index where current positions are stored.
    _impl->ci += _impl->nmax;
    if (_impl->ci >= _impl->max_store)
    {
        _impl->ci = 0;
    }

/*
    for (int i = 0; i < _impl->nmax; ++i)
    {
        _impl->p[_impl->ci + i].bPres = false;
    }
 */
    _impl->nstored++;
    _impl->bFirst = false;
}
EnergyFrame
EnergyFrameReader::frame()
{
    EnergyFrame energyFrame;

    if (!haveProbedForNextFrame_)
    {
        readNextFrame();
    }
    if (!nextFrameExists_)
    {
        GMX_THROW(APIError("There is no next frame, so there should have been no attempt to use the data, e.g. by reacting to a call to readNextFrame()."));
    }

    // The probe filled enxframe_ with new data, so now we use that data to fill energyFrame
    t_enxframe *enxframe = enxframeGuard_.get();
    energyFrame.time_ = enxframe->t;
    energyFrame.step_ = enxframe->step;
    for (auto &index : indicesOfEnergyFields_)
    {
        if (index.second >= enxframe->nre)
        {
            GMX_THROW(InternalError(formatString("Index %d for energy %s not present in energy frame with %d energies",
                                                 index.second, index.first.c_str(), enxframe->nre)));
        }
        energyFrame.values_[index.first] = enxframe->ener[index.second].e;
    }

    // Prepare for reading future frames
    haveProbedForNextFrame_ = false;
    nextFrameExists_        = false;

    return energyFrame;
}
void
AnalysisDataModuleManager::notifyPointsAdd(const AnalysisDataPointSetRef &points) const
{
    GMX_ASSERT(impl_->state_ == Impl::eInFrame, "notifyFrameStart() not called");
    // TODO: Add checks for column spans (requires passing the information
    // about the column counts from somewhere).
    //GMX_ASSERT(points.lastColumn() < columnCount(points.dataSetIndex()),
    //           "Invalid columns");
    GMX_ASSERT(points.frameIndex() == impl_->currIndex_,
               "Points do not correspond to current frame");
    if (impl_->bSerialModules_)
    {
        if (!impl_->bAllowMissing_ && !points.allPresent())
        {
            GMX_THROW(APIError("Missing data not supported by a module"));
        }

        Impl::ModuleList::const_iterator i;
        for (i = impl_->modules_.begin(); i != impl_->modules_.end(); ++i)
        {
            if (!i->bParallel)
            {
                i->module->pointsAdded(points);
            }
        }
    }
}
Exemple #6
0
void
AbstractAnalysisData::Impl::presentData(AbstractAnalysisData *data,
                                        AnalysisDataModuleInterface *module)
{
    module->dataStarted(data);
    bool bCheckMissing = bAllowMissing_
        && !(module->flags() & AnalysisDataModuleInterface::efAllowMissing);
    for (int i = 0; i < data->frameCount(); ++i)
    {
        AnalysisDataFrameRef frame = data->getDataFrame(i);
        GMX_RELEASE_ASSERT(frame.isValid(), "Invalid data frame returned");
        // TODO: Check all frames before doing anything for slightly better
        // exception behavior.
        if (bCheckMissing && !frame.allPresent())
        {
            GMX_THROW(APIError("Missing data not supported by a module"));
        }
        module->frameStarted(frame.header());
        module->pointsAdded(frame.points());
        module->frameFinished(frame.header());
    }
    if (!bInData_)
    {
        module->dataFinished();
    }
}
void
AnalysisDataModuleManager::notifyParallelPointsAdd(
    const AnalysisDataPointSetRef &points) const
{
    // TODO: Add checks for column spans (requires passing the information
    // about the column counts from somewhere).
    //GMX_ASSERT(points.lastColumn() < columnCount(points.dataSetIndex()),
    //           "Invalid columns");
    if (impl_->bParallelModules_)
    {
        if (!impl_->bAllowMissing_ && !points.allPresent())
        {
            GMX_THROW(APIError("Missing data not supported by a module"));
        }

        Impl::ModuleList::const_iterator i;
        for (i = impl_->modules_.begin(); i != impl_->modules_.end(); ++i)
        {
            if (i->bParallel)
            {
                i->module->pointsAdded(points);
            }
        }
    }
}
Exemple #8
0
void Application::createDisplay(uint width, uint height,
                            uint redBits, uint greenBits, uint blueBits,
                            uint alphaBits, uint depthBits, uint stencilBits,
                            DisplayMode mode, const std::string &title)
{
    GLboolean status;
    status = glfwOpenWindow(width, height, redBits, greenBits, blueBits, 
                    alphaBits, depthBits, stencilBits,
                    mode == DISP_FULLSCREEN ? GLFW_FULLSCREEN : GLFW_WINDOW);
    if(status == GL_FALSE)
    {
        throw APIError("Failed to create display.");
    }
    
    // fetch window size (fixes X11 fullscreen bug)
    glfwGetWindowSize(reinterpret_cast<int*>(&displayWidth_), 
                        reinterpret_cast<int*>(&displayHeight_));
    
    glfwSetWindowTitle(title.c_str());  // title is set separately
    
    initOpenGL();
    setOrthoView();
    
    // register the callbacks (after a window is open)
    glfwSetKeyCallback(Application::keyCallback);
    //glfwSetCharCallback(Application::charCallback);
    glfwSetMouseButtonCallback(Application::mouseButtonCallback);
    glfwSetMousePosCallback(Application::mouseMoveCallback);
    glfwSetMouseWheelCallback(Application::mouseWheelCallback);
    
    quit_ = false;
}
void
AnalysisDataModuleManager::Impl::presentData(AbstractAnalysisData        *data,
        AnalysisDataModuleInterface *module)
{
    if (state_ == eNotStarted)
    {
        return;
    }
    GMX_RELEASE_ASSERT(state_ != eInFrame,
                       "Cannot apply a modules in mid-frame");
    module->dataStarted(data);
    const bool bCheckMissing = bAllowMissing_
                               && !(module->flags() & AnalysisDataModuleInterface::efAllowMissing);
    for (int i = 0; i < data->frameCount(); ++i)
    {
        AnalysisDataFrameRef frame = data->getDataFrame(i);
        GMX_RELEASE_ASSERT(frame.isValid(), "Invalid data frame returned");
        // TODO: Check all frames before doing anything for slightly better
        // exception behavior.
        if (bCheckMissing && !frame.allPresent())
        {
            GMX_THROW(APIError("Missing data not supported by a module"));
        }
        module->frameStarted(frame.header());
        for (int j = 0; j < frame.pointSetCount(); ++j)
        {
            module->pointsAdded(frame.pointSet(j));
        }
        module->frameFinished(frame.header());
    }
    if (state_ == eFinished)
    {
        module->dataFinished();
    }
}
Exemple #10
0
void
AnalysisDataVectorPlotModule::pointsAdded(const AnalysisDataPointSetRef &points)
{
    if (points.firstColumn() % DIM != 0 || points.columnCount() % DIM != 0)
    {
        GMX_THROW(APIError("Partial data points"));
    }
    if (!isFileOpen())
    {
        return;
    }
    for (int i = 0; i < points.columnCount(); i += 3)
    {
        for (int d = 0; d < DIM; ++d)
        {
            if (bWrite_[i])
            {
                writeValue(points.values()[i + d]);
            }
        }
        if (bWrite_[DIM])
        {
            const rvec        y = { points.y(i), points.y(i + 1), points.y(i + 2) };
            AnalysisDataValue value(norm(y));
            writeValue(value);
        }
    }
}
void
AbstractAnalysisData::notifyPointsAdd(int firstcol, int n,
                                      const real *y, const real *dy,
                                      const bool *present) const
{
    GMX_ASSERT(_impl->_bInData, "notifyDataStart() not called");
    GMX_ASSERT(_impl->_bInFrame, "notifyFrameStart() not called");
    GMX_ASSERT(firstcol >= 0 && n > 0 && firstcol + n <= _ncol, "Invalid column");
    if (present && !_impl->_bAllowMissing)
    {
        for (int i = 0; i < n; ++i)
        {
            if (!present[i])
            {
                GMX_THROW(APIError("Missing data not supported by a module"));
            }
        }
    }

    Impl::ModuleList::const_iterator i;
    for (i = _impl->_modules.begin(); i != _impl->_modules.end(); ++i)
    {
        (*i)->pointsAdded(_impl->_currx, _impl->_currdx, firstcol, n,
                          y, dy, present);
    }
}
EnergyFrameReaderPtr
openEnergyFileToReadFields(const std::string              &filename,
                           const std::vector<std::string> &namesOfRequiredEnergyFields)
{
    ener_file_ptr energyFile(open_enx(filename.c_str(), "r"));

    if (!energyFile)
    {
        GMX_THROW(FileIOError("Could not open energy file " + filename + " for reading"));
    }

    /* Read in the names of energy fields used in this file. The
     * resulting data structure would leak if an exception was thrown,
     * so transfer the contents that we actually need to a map we can
     * keep.
     *
     * TODO Technically, the insertions into the map could throw
     * std::bad_alloc and we could leak memory allocated by
     * do_enxnms(), but there's nothing we can do about this right
     * now. */
    std::map<std::string, int> indicesOfEnergyFields;
    {
        int          numEnergyTerms;
        gmx_enxnm_t *energyNames = nullptr;
        do_enxnms(energyFile.get(), &numEnergyTerms, &energyNames);
        for (int i = 0; i != numEnergyTerms; ++i)
        {
            const char *name           = energyNames[i].name;
            auto        requiredEnergy = std::find_if(std::begin(namesOfRequiredEnergyFields),
                                                      std::end(namesOfRequiredEnergyFields),
                                                      [name](const std::string &n){
                                                          return 0 == n.compare(name);
                                                      });
            if (requiredEnergy != namesOfRequiredEnergyFields.end())
            {
                indicesOfEnergyFields[name] = i;
            }
        }
        // Clean up old data structures
        free_enxnms(numEnergyTerms, energyNames);
    }

    // Throw if we failed to find the fields we need
    if (indicesOfEnergyFields.size() != namesOfRequiredEnergyFields.size())
    {
        std::string requiredEnergiesNotFound = "Did not find the following required energies in mdrun output:\n";
        for (auto &name : namesOfRequiredEnergyFields)
        {
            auto possibleIndex = indicesOfEnergyFields.find(name);
            if (possibleIndex == indicesOfEnergyFields.end())
            {
                requiredEnergiesNotFound += name + "\n";
            }
        }
        GMX_THROW(APIError(requiredEnergiesNotFound));
    }

    return EnergyFrameReaderPtr(new EnergyFrameReader(indicesOfEnergyFields, energyFile.release()));
}
void SearchController::startAction()
{
    checkParams({"pattern", "category", "plugins"});

    if (!Utils::ForeignApps::pythonInfo().isValid())
        throw APIError(APIErrorType::Conflict, "Python must be installed to use the Search Engine.");

    const QString pattern = params()["pattern"].trimmed();
    const QString category = params()["category"].trimmed();
    const QStringList plugins = params()["plugins"].split('|');

    QStringList pluginsToUse;
    if (plugins.size() == 1) {
        const QString pluginsLower = plugins[0].toLower();
        if (pluginsLower == "all")
            pluginsToUse = SearchPluginManager::instance()->allPlugins();
        else if ((pluginsLower == "enabled") || (pluginsLower == "multi"))
            pluginsToUse = SearchPluginManager::instance()->enabledPlugins();
        else
            pluginsToUse << plugins;
    }
    else {
        pluginsToUse << plugins;
    }

    ISession *const session = sessionManager()->session();
    auto activeSearches = session->getData<QSet<int>>(ACTIVE_SEARCHES);
    if (activeSearches.size() >= MAX_CONCURRENT_SEARCHES)
        throw APIError(APIErrorType::Conflict, QString("Unable to create more than %1 concurrent searches.").arg(MAX_CONCURRENT_SEARCHES));

    const auto id = generateSearchId();
    const SearchHandlerPtr searchHandler {SearchPluginManager::instance()->startSearch(pattern, category, pluginsToUse)};
    QObject::connect(searchHandler.data(), &SearchHandler::searchFinished, this, [session, id, this]() { searchFinished(session, id); });
    QObject::connect(searchHandler.data(), &SearchHandler::searchFailed, this, [session, id, this]() { searchFailed(session, id); });

    auto searchHandlers = session->getData<SearchHandlerDict>(SEARCH_HANDLERS);
    searchHandlers.insert(id, searchHandler);
    session->setData(SEARCH_HANDLERS, QVariant::fromValue(searchHandlers));

    activeSearches.insert(id);
    session->setData(ACTIVE_SEARCHES, QVariant::fromValue(activeSearches));

    const QJsonObject result = {{"id", id}};
    setResult(result);
}
AbstractAnalysisData &TrajectoryAnalysisModule::datasetFromName(const char *name) const
{
    Impl::DatasetContainer::const_iterator item = impl_->datasets_.find(name);
    if (item == impl_->datasets_.end())
    {
        GMX_THROW(APIError("Unknown data set name"));
    }
    return *item->second;
}
bool
EnergyFrameReader::readNextFrame()
{
    if (haveProbedForNextFrame_)
    {
        if (nextFrameExists_)
        {
            GMX_THROW(APIError("This frame has already been probed for, it should be used before probing again."));
        }
        else
        {
            GMX_THROW(APIError("This frame has already been probed for, it doesn't exist, so there should not be subsequent attempts to probe for it."));
        }
    }
    haveProbedForNextFrame_ = true;
    // If there's a next frame, read it into enxframe_, and report the result.
    return nextFrameExists_ = do_enx(energyFileGuard_.get(), enxframeGuard_.get());
}
const real &EnergyFrame::at(const std::string &name) const
{
    auto valueIterator = values_.find(name);
    if (valueIterator == values_.end())
    {
        GMX_THROW(APIError("Cannot get energy value " + name + " unless previously registered when constructing EnergyFrameReader"));
    }
    return valueIterator->second;
}
Exemple #17
0
AnalysisDataFrameRef
AbstractAnalysisData::getDataFrame(int index) const
{
    AnalysisDataFrameRef frame = tryGetDataFrame(index);
    if (!frame.isValid())
    {
        GMX_THROW(APIError("Invalid frame accessed"));
    }
    return frame;
}
Exemple #18
0
OptionInfo *Options::addOption(const AbstractOption &settings)
{
    AbstractOptionStoragePointer option(settings.createStorage());
    if (impl_->findOption(option->name().c_str()) != NULL)
    {
        GMX_THROW(APIError("Duplicate option: " + option->name()));
    }
    impl_->options_.push_back(move(option));
    return &impl_->options_.back()->optionInfo();
}
Exemple #19
0
util::VersionInfo Application::initGLFW()
{
    int maj,min,patch;
    if(glfwInit() == GL_FALSE)
    {
        throw APIError("Initialization of GLFW failed!");
    }
    glfwGetVersion(&maj,&min,&patch);
    return util::VersionInfo(maj,min,patch);
}
// GET param:
//   - hash (string): torrent hash
//   - rid (int): last response id
void SyncController::torrentPeersAction()
{
    auto lastResponse = sessionManager()->session()->getData(QLatin1String("syncTorrentPeersLastResponse")).toMap();
    auto lastAcceptedResponse = sessionManager()->session()->getData(QLatin1String("syncTorrentPeersLastAcceptedResponse")).toMap();

    const QString hash {params()["hash"]};
    BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(hash);
    if (!torrent)
        throw APIError(APIErrorType::NotFound);

    QVariantMap data;
    QVariantHash peers;
    const QList<BitTorrent::PeerInfo> peersList = torrent->peers();
#ifndef DISABLE_COUNTRIES_RESOLUTION
    bool resolvePeerCountries = Preferences::instance()->resolvePeerCountries();
#else
    bool resolvePeerCountries = false;
#endif

    data[KEY_SYNC_TORRENT_PEERS_SHOW_FLAGS] = resolvePeerCountries;

    for (const BitTorrent::PeerInfo &pi : peersList) {
        if (pi.address().ip.isNull()) continue;
        QVariantMap peer;
#ifndef DISABLE_COUNTRIES_RESOLUTION
        if (resolvePeerCountries) {
            peer[KEY_PEER_COUNTRY_CODE] = pi.country().toLower();
            peer[KEY_PEER_COUNTRY] = Net::GeoIPManager::CountryName(pi.country());
        }
#endif
        peer[KEY_PEER_IP] = pi.address().ip.toString();
        peer[KEY_PEER_PORT] = pi.address().port;
        peer[KEY_PEER_CLIENT] = pi.client();
        peer[KEY_PEER_PROGRESS] = pi.progress();
        peer[KEY_PEER_DOWN_SPEED] = pi.payloadDownSpeed();
        peer[KEY_PEER_UP_SPEED] = pi.payloadUpSpeed();
        peer[KEY_PEER_TOT_DOWN] = pi.totalDownload();
        peer[KEY_PEER_TOT_UP] = pi.totalUpload();
        peer[KEY_PEER_CONNECTION_TYPE] = pi.connectionType();
        peer[KEY_PEER_FLAGS] = pi.flags();
        peer[KEY_PEER_FLAGS_DESCRIPTION] = pi.flagsDescription();
        peer[KEY_PEER_RELEVANCE] = pi.relevance();
        peer[KEY_PEER_FILES] = torrent->info().filesForPiece(pi.downloadingPieceIndex()).join(QLatin1String("\n"));

        peers[pi.address().ip.toString() + ':' + QString::number(pi.address().port)] = peer;
    }

    data["peers"] = peers;

    const int acceptedResponseId {params()["rid"].toInt()};
    setResult(QJsonObject::fromVariantMap(generateSyncData(acceptedResponseId, data, lastAcceptedResponse, lastResponse)));

    sessionManager()->session()->setData(QLatin1String("syncTorrentPeersLastResponse"), lastResponse);
    sessionManager()->session()->setData(QLatin1String("syncTorrentPeersLastAcceptedResponse"), lastAcceptedResponse);
}
Exemple #21
0
static Any
get_clipboard_data(DisplayObj d, Name type)
{ HGLOBAL mem;
  HENHMETAFILE hmf;
  Any rval = FAIL;

  OpenClipboard(CLIPBOARDWIN);
  if ( type != NAME_winMetafile && (mem = GetClipboardData(CF_UNICODETEXT)) )
  { wchar_t *data = GlobalLock(mem);
    wchar_t *copy, *q;

    q = copy = pceMalloc((wcslen(data)+1)*sizeof(wchar_t));

    for(; *data; data++)
    { if ( *data == '\r' && data[1] == '\n' )
      { data++;
	*q++ = '\n';
      } else
	*q++ = *data;
    }
    *q = EOS;
    rval = WCToString(copy, q-copy);
    pceFree(copy);
    GlobalUnlock(mem);
  } else if ( type != NAME_winMetafile && (mem = GetClipboardData(CF_TEXT)) )
  { char far *data = GlobalLock(mem);
    char *copy, *q;

    q = copy = pceMalloc(strlen(data));

    for(; *data; data++)
    { if ( *data == '\r' && data[1] == '\n' )
      { data++;
	*q++ = '\n';
      } else
	*q++ = *data;
    }
    *q = EOS;
    rval = CtoString(copy);
    pceFree(copy);
    GlobalUnlock(mem);
  } else if ( type != NAME_text && (hmf = GetClipboardData(CF_ENHMETAFILE)) )
  { HENHMETAFILE copy = CopyEnhMetaFile(hmf, NULL);
    if ( !copy )
    { errorPce(d, NAME_winMetafile, CtoName("CopyEnhMetaFile"), APIError());
      fail;
    }

    rval = CtoWinMetafile(copy);
    DeleteEnhMetaFile(hmf);
  }
  CloseClipboard();

  return rval;
}
//==============================================================================
// main - this is the main module for our application.  It handle the
//        initialization of the window, going into a message loop for
//        dispatching messages and terminates the window upon successful exit
//        from the message loop
//==============================================================================
void cdecl main( void ) {
   // initialize the main instance of our application

   if (Main::Initialize()==FALSE)
      APIError((HWND)NULL,(HWND)NULL);
   {
        AppWindow MainWnd;               // initialize our application window
        Main::FramehWnd = MainWnd.GetFrameHandle();
        Main::MessageLoop();             // call our message handler for our app
   }
   Main::Terminate();                   // terminate the application
}
AbstractAnalysisData &TrajectoryAnalysisModule::datasetFromIndex(int index) const
{
    if (index < 0 || index >= datasetCount())
    {
        GMX_THROW(APIError("Out of range data set index"));
    }
    Impl::DatasetContainer::const_iterator item
        = impl_->datasets_.find(impl_->datasetNames_[index]);
    GMX_RELEASE_ASSERT(item != impl_->datasets_.end(),
                       "Inconsistent data set names");
    return *item->second;
}
Exemple #24
0
bool
TrajectoryFrameReader::readNextFrame()
{
    if (haveProbedForNextFrame_)
    {
        if (nextFrameExists_)
        {
            GMX_THROW(APIError("This frame has already been probed for, it should be used before probing again."));
        }
        else
        {
            GMX_THROW(APIError("This frame has already been probed for, it doesn't exist, so there should not be subsequent attempts to probe for it."));
        }
    }
    haveProbedForNextFrame_ = true;
    // If there's a next frame, read it into trxframe_, and report the result.
    if (!haveReadFirstFrame_)
    {
        t_trxstatus *trajectoryFile;
        int          flags = TRX_READ_X | TRX_READ_V | TRX_READ_F;
        nextFrameExists_ = read_first_frame(oenvGuard_.get(),
                                            &trajectoryFile,
                                            filename_.c_str(),
                                            trxframeGuard_.get(),
                                            flags);
        if (!trajectoryFile)
        {
            GMX_THROW(FileIOError("Could not open trajectory file " + filename_ + " for reading"));
        }
        trajectoryFileGuard_.reset(trajectoryFile);
        haveReadFirstFrame_ = true;
    }
    else
    {
        nextFrameExists_ = read_next_frame(oenvGuard_.get(),
                                           trajectoryFileGuard_.get(),
                                           trxframeGuard_.get());
    }
    return nextFrameExists_;
}
Exemple #25
0
void
AnalysisDataDisplacementModule::pointsAdded(const AnalysisDataPointSetRef &points)
{
    if (points.firstColumn() % _impl->ndim != 0
        || points.columnCount() % _impl->ndim != 0)
    {
        GMX_THROW(APIError("Partial data points"));
    }
    for (int i = 0; i < points.columnCount(); ++i)
    {
        _impl->oldval[_impl->ci + points.firstColumn() + i] = points.y(i);
    }
}
void
AnalysisDataDisplacementModule::pointsAdded(real x, real dx, int firstcol, int n,
                                            const real *y, const real *dy,
                                            const bool *present)
{
    if (firstcol % _impl->ndim != 0 || n % _impl->ndim != 0)
    {
        GMX_THROW(APIError("Partial data points"));
    }
    for (int i = firstcol; i < firstcol + n; ++i)
    {
        _impl->oldval[_impl->ci + i] = y[i];
    }
}
void
AbstractAnalysisData::applyModule(AnalysisDataModuleInterface *module)
{
    if ((columnCount() > 1 && !(module->flags() & AnalysisDataModuleInterface::efAllowMulticolumn))
        || (isMultipoint() && !(module->flags() & AnalysisDataModuleInterface::efAllowMultipoint))
        || (!isMultipoint() && (module->flags() & AnalysisDataModuleInterface::efOnlyMultipoint)))
    {
        GMX_THROW(APIError("Data module not compatible with data object properties"));
    }
    GMX_RELEASE_ASSERT(_impl->_bDataStart && !_impl->_bInData,
                       "Data module can only be applied to ready data");

    _impl->presentData(this, module);
}
void
AbstractAnalysisData::Impl::presentData(AbstractAnalysisData *data,
                                        AnalysisDataModuleInterface *module)
{
    module->dataStarted(data);
    bool bCheckMissing = _bAllowMissing
        && !(module->flags() & AnalysisDataModuleInterface::efAllowMissing);
    int ncol = data->columnCount();
    for (int i = 0; i < data->frameCount(); ++i)
    {
        real        x, dx;
        const real *y, *dy;
        const bool *present;

        if (!data->getDataWErr(i, &x, &dx, &y, &dy, &present))
        {
            GMX_THROW(APIError("Data not available when module added"));
        }
        if (bCheckMissing && present)
        {
            for (int j = 0; j < ncol; ++j)
            {
                if (!present[j])
                {
                    GMX_THROW(APIError("Missing data not supported by a module"));
                }
            }
        }
        module->frameStarted(x, dx);
        module->pointsAdded(x, dx, 0, ncol, y, dy, present);
        module->frameFinished();
    }
    if (!_bInData)
    {
        module->dataFinished();
    }
}
Exemple #29
0
void
AnalysisDataDisplacementModule::dataStarted(AbstractAnalysisData *data)
{
    if (data->columnCount() % _impl->ndim != 0)
    {
        GMX_THROW(APIError("Data has incorrect number of columns"));
    }
    _impl->nmax = data->columnCount();
    snew(_impl->oldval, _impl->nmax);
    _impl->ci = -_impl->nmax;

    int ncol = _impl->nmax / _impl->ndim + 1;
    _impl->currValues_.reserve(ncol);
    setColumnCount(ncol);
}
Exemple #30
0
void
TopologyInformation::getTopologyConf(rvec **x, matrix box) const
{
    if (box)
    {
        copy_mat(const_cast<rvec *>(boxtop_), box);
    }
    if (x)
    {
        if (!xtop_)
        {
            *x = NULL;
            GMX_THROW(APIError("Topology coordinates requested without setting efUseTopX"));
        }
        *x = xtop_;
    }
}