Example #1
0
void
TrajectoryAnalysisRunnerCommon::initTopology(SelectionCollection *selections)
{
    // Return immediately if the topology has already been loaded.
    if (impl_->topInfo_.hasTopology())
    {
        return;
    }

    const TrajectoryAnalysisSettings &settings = impl_->settings_;
    const bool bRequireTop
        = settings.hasFlag(TrajectoryAnalysisSettings::efRequireTop)
            || selections->requiresTopology();
    if (bRequireTop && impl_->topfile_.empty())
    {
        GMX_THROW(InconsistentInputError("No topology provided, but one is required for analysis"));
    }

    // Load the topology if requested.
    if (!impl_->topfile_.empty())
    {
        char  title[STRLEN];

        snew(impl_->topInfo_.top_, 1);
        impl_->topInfo_.bTop_ = read_tps_conf(impl_->topfile_.c_str(), title,
                                              impl_->topInfo_.top_, &impl_->topInfo_.ePBC_,
                                              &impl_->topInfo_.xtop_, NULL, impl_->topInfo_.boxtop_, TRUE);
        if (hasTrajectory()
            && !settings.hasFlag(TrajectoryAnalysisSettings::efUseTopX))
        {
            sfree(impl_->topInfo_.xtop_);
            impl_->topInfo_.xtop_ = NULL;
        }
    }

    // Read the first frame if we don't know the maximum number of atoms
    // otherwise.
    int  natoms = -1;
    if (!impl_->topInfo_.hasTopology())
    {
        initFirstFrame();
        natoms = impl_->fr->natoms;
    }
    selections->setTopology(impl_->topInfo_.topology(), natoms);

    /*
       if (impl_->bSelDump)
       {
        gmx_ana_poscalc_coll_print_tree(stderr, impl_->pcc);
        fprintf(stderr, "\n");
       }
     */
}
Example #2
0
 virtual int getAtomCount()
 {
     if (!topInfo_.hasTopology())
     {
         if (trajectoryGroup_.isValid())
         {
             GMX_THROW(InconsistentInputError("-fgroup is only supported when -s is also specified"));
         }
         // Read the first frame if we don't know the maximum number of
         // atoms otherwise.
         initFirstFrame();
         return fr->natoms;
     }
     return -1;
 }