/** Print atoms for which the cumulative energy satisfies the given * cutoffs. Also create MOL2 files containing those atoms. */ int Action_Pairwise::PrintCutAtoms(Frame const& frame, int frameNum, EoutType ctype, Darray const& Earray, double cutIn) { AtomMask CutMask; // Hold atoms that satisfy the cutoff Darray CutCharges; // Hold evdw/eelec corresponding to CutMask atoms. if (Eout_ != 0) { if (nb_calcType_==COMPARE_REF) Eout_->Printf("\tPAIRWISE: Cumulative d%s:", CalcString[ctype]); else Eout_->Printf("\tPAIRWISE: Cumulative %s:", CalcString[ctype]); Eout_->Printf(" %s < %.4f, %s > %.4f\n", CalcString[ctype], -cutIn, CalcString[ctype], cutIn); } for (AtomMask::const_iterator atom = Mask0_.begin(); atom != Mask0_.end(); ++atom) { if (fabs(Earray[*atom]) > cutIn) { if (Eout_ != 0) Eout_->Printf("\t\t%6i@%s: %12.4f\n", *atom+1, (*CurrentParm_)[*atom].c_str(), Earray[*atom]); CutMask.AddAtom(*atom); CutCharges.push_back(Earray[*atom]); } } // Write mol2 with atoms satisfying cutoff if (!mol2Prefix_.empty() && !CutMask.None()) { if (WriteCutFrame(frameNum, *CurrentParm_, CutMask, CutCharges, frame, mol2Prefix_ + CutName[ctype])) return 1; } return 0; }
Action::RetType Action_AtomicCorr::Setup(ActionSetup& setup) { if (setup.Top().SetupIntegerMask( mask_ )) return Action::ERR; mask_.MaskInfo(); if (mask_.None()) return Action::SKIP; if (acorr_mode_ == ATOM) { // Setup output array; labels and index atom_vectors_.clear(); for (AtomMask::const_iterator atom = mask_.begin(); atom != mask_.end(); ++atom) atom_vectors_.push_back( AtomVector(integerToString( *atom + 1 ), *atom) ); } else { std::map<int,AtomMask> rmaskmap; // Find which residues selected atoms belong to. for (AtomMask::const_iterator atom = mask_.begin(); atom != mask_.end(); ++atom) { int current_res = setup.Top()[*atom].ResNum(); std::map<int,AtomMask>::iterator rmask = rmaskmap.find( current_res ); if ( rmask == rmaskmap.end() ) { // Residue not yet in map. AtomMask newmask; newmask.AddAtom( *atom ); rmaskmap.insert( std::pair<int,AtomMask>( current_res, newmask ) ); } else { // Residue is already in map. Add this atom. rmask->second.AddAtom( *atom ); } } // Place selected residues in mask vector and setup output array; labels and index. resmasks_.clear(); atom_vectors_.clear(); for (std::map<int,AtomMask>::const_iterator rmask = rmaskmap.begin(); rmask != rmaskmap.end(); ++rmask) { if (debug_ > 0) mprintf("DBG:\tRes mask for %i has %i atoms\n", rmask->first, rmask->second.Nselected()); resmasks_.push_back( rmask->second ); atom_vectors_.push_back( AtomVector( setup.Top().TruncResNameNum( rmask->first ), rmask->first ) ); } mprintf("\tSelected %zu residues.\n", resmasks_.size()); } return Action::OK; }