void loadModel( const char *coordinates, const char *polygons, std::vector<Angel::vec3> *verts, std::vector<Angel::vec3> *data ) { readCoords( coordinates, verts ); std::cout << "Read coordinates file successfully." << std::endl; readPolygons( polygons, verts, data ); std::cout << "Read polygon file successfully." << std::endl; }
void bi::InputNetCDFBuffer::readMask0(const VarType type, Mask<ON_HOST>& mask) { typedef temp_host_matrix<real>::type temp_matrix_type; mask.resize(m.getNumVars(type), false); Var* var; int r; long start, len; /* sparse masks */ for (r = 0; r < int(recDims.size()); ++r) { if (timeVars[r] < 0) { BOOST_AUTO(range, modelVars.equal_range(r)); BOOST_AUTO(iter, range.first); BOOST_AUTO(end, range.second); start = 0; len = nc_inq_dimlen(ncid, recDims[r]); temp_matrix_type C(iter->second->getNumDims(), len); readCoords(coordVars[r], start, len, C); for (; iter != end; ++iter) { var = iter->second; if (var->getType() == type) { mask.addSparseMask(var->getId(), C.size2()); serialiseCoords(var, C, mask.getIndices(var->getId())); } } } } /* dense masks */ r = -1; // for those vars not associated with a record dimension BOOST_AUTO(range, modelVars.equal_range(r)); BOOST_AUTO(iter, range.first); BOOST_AUTO(end, range.second); for (; iter != end; ++iter) { var = iter->second; if (var->getType() == type) { mask.addDenseMask(var->getId(), var->getSize()); } } }
void bi::InputNetCDFBuffer::readMask(const size_t k, const VarType type, Mask<ON_HOST>& mask) { typedef temp_host_matrix<real>::type temp_matrix_type; mask.resize(m.getNumVars(type), false); Var* var; int r; long start, len; for (r = 0; r < int(recDims.size()); ++r) { if (timeVars[r] >= 0) { start = recStarts[k][r]; len = recLens[k][r]; if (len > 0) { BOOST_AUTO(range, modelVars.equal_range(r)); BOOST_AUTO(iter, range.first); BOOST_AUTO(end, range.second); if (coordVars[r] >= 0) { /* sparse mask */ temp_matrix_type C(iter->second->getNumDims(), len); readCoords(coordVars[r], start, len, C); for (; iter != end; ++iter) { var = iter->second; if (var->getType() == type) { mask.addSparseMask(var->getId(), len); serialiseCoords(var, C, mask.getIndices(var->getId())); } } } else { /* dense mask */ for (; iter != end; ++iter) { var = iter->second; if (var->getType() == type) { mask.addDenseMask(var->getId(), var->getSize()); } } } } } } }
bool WRL1BASE::ReadNode( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode ) { // This function reads a node and stores a pointer to it in aNode. // A value 'true' is returned if a node is successfully read or, // if the node is not supported, successfully discarded. Callers // must always check the value of aNode when the function returns // 'true' since it will be NULL if the node type is not supported. if( NULL != aNode ) *aNode = NULL; if( NULL == aParent ) { #ifdef DEBUG_VRML1 do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [BUG] invalid parent pointer (NULL)"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); #endif return false; } std::string glob; WRL1NODES ntype; if( !proc.ReadName( glob ) ) { #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) if( !proc.eof() ) { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << proc.GetError(); wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } #endif return false; } // Process node name: // the names encountered at this point should be one of the // built-in node names or one of: // DEF, USE if( !glob.compare( "USE" ) ) { if( !implementUse( proc, aParent, aNode ) ) { #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << proc.GetError(); wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); #endif return false; } return true; } if( !glob.compare( "DEF" ) ) { if( !implementDef( proc, aParent, aNode ) ) { #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << proc.GetError(); wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); #endif return false; } return true; } ntype = getNodeTypeID( glob ); size_t line = 0; size_t column = 0; proc.GetFilePosData( line, column ); #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 ) do { std::ostringstream ostr; ostr << " * [INFO] Processing node '" << glob << "' ID: " << ntype; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); #endif switch( ntype ) { case WRL1_GROUP: if( !readGroup( proc, aParent, aNode ) ) return false; break; case WRL1_SEPARATOR: if( !readSeparator( proc, aParent, aNode ) ) return false; break; case WRL1_SWITCH: if( !readSwitch( proc, aParent, aNode ) ) return false; break; case WRL1_MATERIAL: if( !readMaterial( proc, aParent, aNode ) ) return false; break; case WRL1_MATERIALBINDING: if( !readMatBinding( proc, aParent, aNode ) ) return false; break; case WRL1_COORDINATE3: if( !readCoords( proc, aParent, aNode ) ) return false; break; case WRL1_INDEXEDFACESET: if( !readFaceSet( proc, aParent, aNode ) ) return false; break; case WRL1_TRANSFORM: case WRL1_TRANSLATION: case WRL1_ROTATION: case WRL1_SCALE: if( !readTransform( proc, aParent, aNode ) ) return false; break; case WRL1_SHAPEHINTS: if( !readShapeHints( proc, aParent, aNode ) ) return false; break; // // items not implemented or for optional future implementation: // default: proc.GetFilePosData( line, column ); if( !proc.DiscardNode() ) { #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) do { std::ostringstream ostr; ostr << proc.GetError() << "\n"; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [INFO] could not discard node at line " << line; ostr << ", column " << column; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); #endif return false; } #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) else { std::ostringstream ostr; ostr << " * [INFO] discarded node '" << glob << "' at line "; ostr << line << ", col " << column << " (currently unsupported)"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } #endif break; } return true; }
int gmx_tilt(int argc, char *argv[]) { const char *desc[] = { "\tLook at the tilt angle of RalGDS when docked to different\n", "GTPases: p21Ras (1LFD.pdb) and Rap1a (1GUA.pdb).", "\tUse -s for the simulated molecule topology. Use -fr for\n", "the reference molecule topology.\n", "\n", "Workflow:\n", "\t1) VMD STAMP Structural alignment of reference structure to\n", "\t 1LFD.pdb chain B (Ras).\n", "\t2) Make a .tpr of the reference structure (which has already\n", "\t been aligned to 1LFD.pdb, per step 1)\n" "\t3) Kabsch alignment of a single frame of the simulation\n", "\t trajectory to the GTPase of the reference structure.\n", "\t4) Use trjconv to align the GTPase of the simulated trajectory\n", "\t to the (aligned) frame from step 3.\n", "\t5) Run this code.\n", }; gmx_bool bVerbose = FALSE; const char *struct_file, *traj_file; const char *ndx_file, *xvg_file; const char *ref_file; t_tiltdata data; t_pargs pa[] = { { "-v", FALSE, etBOOL, {&bVerbose}, "Be slightly more verbose"}, }; t_filenm fnm[] = { {efTPS, NULL, NULL, ffREAD}, {efTRX, NULL, NULL, ffREAD}, //{efGRO, "-fr", NULL, ffREAD}, {efTPS, "-fr", NULL, ffREAD}, {efXVG, "-o","tilt",ffOPTWR}, {efNDX, NULL, NULL, ffREAD}, }; #define NFILE asize(fnm) #define NPA asize(pa) output_env_t oenv; int ngrps, nrefgrps; t_topology struct_top, ref_top; t_atoms *struct_atoms=NULL, *ref_atoms=NULL; t_trxframe struct_fr, ref_fr; t_trxstatus *struct_status, *ref_status; rvec *struct_xtop, *ref_xtop; matrix struct_box, ref_box; int struct_ePBC, ref_ePBC; int struct_flags=TRX_READ_X, ref_flags=TRX_READ_X; char buffer[1024]; CopyRight(stderr,argv[0]); parse_common_args(&argc, argv, PCA_CAN_BEGIN | PCA_CAN_END | PCA_CAN_VIEW | PCA_TIME_UNIT | PCA_BE_NICE | PCA_CAN_TIME, NFILE, fnm, NPA, pa, asize(desc), desc, 0, NULL, &oenv); /* Get inputs */ struct_file = ftp2fn(efTPS, NFILE, fnm); traj_file = opt2fn( "-f", NFILE, fnm); ref_file = opt2fn("-fr", NFILE, fnm); ndx_file = ftp2fn(efNDX, NFILE, fnm); /* Open inputs */ read_tps_conf(struct_file, buffer, &struct_top, &struct_ePBC, &struct_xtop, NULL, struct_box, TRUE); sfree(struct_xtop); struct_atoms = &struct_top.atoms; read_tps_conf(ref_file, buffer, &ref_top, &ref_ePBC, &ref_xtop, NULL, ref_box, TRUE); ref_atoms = &ref_top.atoms; /* open xvg file */ data.fp = NULL; data.fp = xvgropen(opt2fn("-o", NFILE, fnm), "Center of Mass displacement","Time[ps]","Tilt Angle[degrees]", oenv); const char *flegend[] = { "Time[ps]", "tilt[deg]", "rmsd[nm]", "CoM displacement[nm]", "Rotation axis x-component[nm]", "Rotation axis y-component[nm]", "Rotation axis z-component[nm]", "X-axis rotation[deg]", "Y-axis rotation[deg]", "Z-axis rotation[deg]", }; xvgr_legend(data.fp,asize(flegend),flegend,oenv); /* Get index information */ static int n_structatoms, n_refatoms; atom_id *ind_structatoms, *ind_refatoms; char *gn_structatoms, *gn_refatoms; int i_structatoms, i_refatoms; std::cout<< "\nSelect group from reference structure <" << ref_file << ">." << std::endl; get_index(ref_atoms, ndx_file, 1, &n_refatoms, &ind_refatoms, &gn_refatoms); std::cout<< "\nSelect group from simulation structure(s) <" << struct_file <<"> to compare to the reference structure, <" << ref_file << ">." << std::endl; get_index(struct_atoms, ndx_file, 1, &n_structatoms, &ind_structatoms, &gn_structatoms); if ( n_structatoms != n_refatoms ) { gmx_fatal(FARGS, "\nThe number of atoms in the index groups are different."); } /* read the reference file and get coordinates */ std::vector<float> ref_coords(n_refatoms*3,0); readCoords(n_refatoms, ind_refatoms, ref_xtop, &ref_top, ref_coords, bVerbose); /* read trajectory file and loop through frames */ int nframes = 0; read_first_frame(oenv, &struct_status, traj_file, &struct_fr, struct_flags); do { std::vector<float> struct_coords(n_structatoms*3,0); readCoords(n_structatoms, ind_structatoms, &struct_fr, &struct_top, struct_coords, bVerbose); displacement(ref_coords, struct_coords, data, bVerbose); kabsch_alignment(ref_coords,struct_coords, data, bVerbose); data.time.push_back(struct_fr.time); nframes++; } while(read_next_frame(oenv, struct_status, &struct_fr)); for (int i=0; i<nframes; i++) { fprintf(data.fp,"%8.2f %8.2f %8.3f %8.3f %12.6f %12.6f %12.6f %8.2f %8.2f %8.2f\n",data.time[i],data.rotation[i],data.rmsd[i],data.distance[i],data.x_rotation_axis[i],data.y_rotation_axis[i],data.z_rotation_axis[i],data.x_rotation[i],data.y_rotation[i],data.z_rotation[i]); } return 0; }