本文整理汇总了C++中PDB::readFromFilepointer方法的典型用法代码示例。如果您正苦于以下问题:C++ PDB::readFromFilepointer方法的具体用法?C++ PDB::readFromFilepointer怎么用?C++ PDB::readFromFilepointer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PDB
的用法示例。
在下文中一共展示了PDB::readFromFilepointer方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mymsd
PathMSDBase::PathMSDBase(const ActionOptions&ao):
PLUMED_COLVAR_INIT(ao),
neigh_size(-1),
neigh_stride(-1),
nframes(0)
{
parse("LAMBDA",lambda);
parse("NEIGH_SIZE",neigh_size);
parse("NEIGH_STRIDE",neigh_stride);
parse("REFERENCE",reference);
// open the file
FILE* fp=fopen(reference.c_str(),"r");
std::vector<AtomNumber> aaa;
if (fp!=NULL)
{
log<<"Opening reference file "<<reference.c_str()<<"\n";
bool do_read=true;
while (do_read){
PDB mypdb;
RMSD mymsd(log);
do_read=mypdb.readFromFilepointer(fp,plumed.getAtoms().usingNaturalUnits(),0.1/atoms.getUnits().getLength());
if(do_read){
unsigned nat=0;
nframes++;
if(mypdb.getAtomNumbers().size()==0) error("number of atoms in a frame should be more than zero");
if(nat==0) nat=mypdb.getAtomNumbers().size();
if(nat!=mypdb.getAtomNumbers().size()) error("frames should have the same number of atoms");
if(aaa.empty()) aaa=mypdb.getAtomNumbers();
if(aaa!=mypdb.getAtomNumbers()) error("frames should contain same atoms in same order");
log<<"Found PDB: "<<nframes<<" containing "<<mypdb.getAtomNumbers().size()<<" atoms\n";
pdbv.push_back(mypdb);
// requestAtoms(mypdb.getAtomNumbers()); // is done in non base classes
derivs_s.resize(mypdb.getAtomNumbers().size());
derivs_z.resize(mypdb.getAtomNumbers().size());
mymsd.set(mypdb,"OPTIMAL");
msdv.push_back(mymsd); // the vector that stores the frames
//log<<mypdb;
}else{break ;}
}
fclose (fp);
log<<"Found TOTAL "<<nframes<< " PDB in the file "<<reference.c_str()<<" \n";
if(nframes==0) error("at least one frame expected");
}
if(neigh_stride>0 || neigh_size>0){
if(neigh_size>int(nframes)){
log.printf(" List size required ( %d ) is too large: resizing to the maximum number of frames required: %u \n",neigh_size,nframes);
neigh_size=nframes;
}
log.printf(" Neighbor list enabled: \n");
log.printf(" size : %d elements\n",neigh_size);
log.printf(" stride : %d timesteps \n",neigh_stride);
}else{
log.printf(" Neighbor list NOT enabled \n");
}
}
示例2: parse
Mapping::Mapping(const ActionOptions&ao):
Action(ao),
ActionAtomistic(ao),
ActionWithArguments(ao),
ActionWithValue(ao),
ActionWithVessel(ao)
{
// Read the input
std::string mtype; parse("TYPE",mtype);
bool skipchecks; parseFlag("DISABLE_CHECKS",skipchecks);
// Setup the object that does the mapping
mymap = new PointWiseMapping( mtype, skipchecks );
// Read the properties we require
if( keywords.exists("PROPERTY") ){
std::vector<std::string> property;
parseVector("PROPERTY",property);
if(property.size()==0) error("no properties were specified");
mymap->setPropertyNames( property, false );
} else {
std::vector<std::string> property(1);
property[0]="sss";
mymap->setPropertyNames( property, true );
}
// Open reference file
std::string reference; parse("REFERENCE",reference);
FILE* fp=fopen(reference.c_str(),"r");
if(!fp) error("could not open reference file " + reference );
// Read all reference configurations
bool do_read=true; std::vector<double> weights;
unsigned nfram=0, wnorm=0., ww;
while (do_read){
PDB mypdb;
// Read the pdb file
do_read=mypdb.readFromFilepointer(fp,plumed.getAtoms().usingNaturalUnits(),0.1/atoms.getUnits().getLength());
// Fix argument names
expandArgKeywordInPDB( mypdb );
if(do_read){
mymap->readFrame( mypdb ); ww=mymap->getWeight( nfram );
weights.push_back( ww );
wnorm+=ww; nfram++;
} else {
break;
}
}
fclose(fp);
if(nfram==0 ) error("no reference configurations were specified");
log.printf(" found %d configurations in file %s\n",nfram,reference.c_str() );
for(unsigned i=0;i<weights.size();++i) weights[i] /= wnorm;
mymap->setWeights( weights );
// Finish the setup of the mapping object
// Get the arguments and atoms that are required
std::vector<AtomNumber> atoms; std::vector<std::string> args;
mymap->getAtomAndArgumentRequirements( atoms, args );
requestAtoms( atoms ); std::vector<Value*> req_args;
interpretArgumentList( args, req_args ); requestArguments( req_args );
// Duplicate all frames (duplicates are used by sketch-map)
mymap->duplicateFrameList();
fframes.resize( 2*nfram, 0.0 ); dfframes.resize( 2*nfram, 0.0 );
plumed_assert( !mymap->mappingNeedsSetup() );
// Resize all derivative arrays
mymap->setNumberOfAtomsAndArguments( atoms.size(), args.size() );
// Resize forces array
if( getNumberOfAtoms()>0 ){
forcesToApply.resize( 3*getNumberOfAtoms() + 9 + getNumberOfArguments() );
} else {
forcesToApply.resize( getNumberOfArguments() );
}
}