├── docs ├── molscript.html ├── _config.yml ├── images │ ├── pdb.gif │ ├── sgi.gif │ ├── vrml.gif │ ├── opengl.gif │ ├── ras_cyl.jpg │ ├── ras_std.jpg │ ├── coordsys.gif │ ├── gnu_head.gif │ ├── ras_coil.jpg │ ├── ras_rmsd.jpg │ ├── ras_shiny.jpg │ ├── ras_trace.jpg │ ├── ras_turn.jpg │ ├── raster3d.gif │ ├── biomedlink.gif │ ├── ghostscript.gif │ ├── ras_gdp_cpk.jpg │ ├── ras_gdp_balls.jpg │ └── ras_gdp_bonds.jpg ├── kraulis_1991_molscript_j_appl_cryst.pdf ├── style.css ├── license.html ├── disclaimer.html ├── LICENSE.txt ├── interface.html ├── distribution.html ├── references.html ├── index.html └── syntax.html ├── .gitignore ├── examples ├── ras_cyl.gif ├── ras_cyl.jpg ├── ras_gdp.jpg ├── ras_gdp.rgb ├── ras_std.gif ├── ras_std.jpg ├── ras_std.png ├── ras_std.rgb ├── ras_std.sgi ├── ras_cyl_gz.wrl ├── ras_gdp_gz.wrl ├── ras_rmsd.jpg ├── ras_rmsd.rgb ├── ras_rmsd.sgi ├── ras_shiny.jpg ├── ras_shiny.png ├── ras_shiny.sgi ├── ras_std_gz.wrl ├── ras_gdp_r3d.jpg ├── ras_molauto.jpg ├── ras_rmsd_r3d.jpg ├── ras_std_r3d.jpg ├── ras_cyl_small.jpg ├── ras_gdp_small.jpg ├── ras_molauto_gz.wrl ├── ras_rmsd_small.jpg ├── ras_shiny_small.jpg ├── ras_std_small.jpg ├── ras_vrml_lod_gz.wrl ├── ras_molauto_nice.jpg ├── ras_molauto_small.jpg ├── ras_molauto_nice_gz.wrl ├── ras_molauto_nice_small.jpg ├── style.css ├── ras_gdp_cpk.in ├── ras_gdp_balls.in ├── ras_frames.html ├── ras_gdp_bonds.in ├── ras_coil.in ├── ras_trace.in ├── ras_turn.in ├── ras_mg_text.html ├── ras_loops_text.html ├── ras_gdp_text.html ├── ras_molauto_nice.in ├── ras_top_text.html ├── ras_molauto.in ├── ras_rmsd.in ├── ras_cyl.in ├── ras_min_vrml.in ├── ras_vrml.in ├── ras_shiny.in ├── ras_std.in ├── ras_vrml_lod.in ├── ras_gdp.in └── Makefile ├── code ├── clib │ ├── ogl_bitmap_character.h │ ├── ogl_utils.h │ ├── mol3d_secstruc.h │ ├── err.h │ ├── args.h │ ├── hermite_curve.h │ ├── boolean.h │ ├── body3d.h │ ├── io_utils.h │ ├── angle.h │ ├── mol3d_chain.h │ ├── element_lookup.h │ ├── key_value.h │ ├── extent3d.h │ ├── mol3d_init.h │ ├── quaternion.h │ ├── named_data.h │ ├── mol3d_io.h │ ├── indent.h │ ├── str_utils.h │ ├── mol3d_utils.h │ ├── matrix3.h │ ├── ogl_body.h │ ├── double_hash.h │ ├── colour.h │ ├── aa_lookup.h │ ├── dynstring.h │ ├── sgi_image.h │ ├── ogl_utils.c │ ├── ogl_bitmap_character.c │ ├── vector3.h │ ├── vrml.h │ ├── Makefile │ ├── args.c │ ├── io_utils.c │ ├── hermite_curve.c │ ├── err.c │ ├── named_data.c │ ├── key_value.c │ ├── mol3d_chain.c │ ├── mol3d.h │ ├── element_lookup.c │ ├── double_hash.c │ └── extent3d.c ├── sgi_img.h ├── image.h ├── eps_img.h ├── png_img.h ├── jpeg_img.h ├── gif_img.h ├── lex.h ├── xform.h ├── col.h ├── postscript.h ├── other │ ├── glutstroke.h │ └── regex.h ├── coord.h ├── raster3d.h ├── opengl.h ├── segment.h ├── vrml.h ├── global.h ├── select.h ├── sgi_img.c ├── jpeg_img.c ├── Makefile.basic ├── graphics.h ├── state.h ├── segment.c ├── molscript.tab.h ├── png_img.c ├── eps_img.c ├── gif_img.c ├── xform.c └── Makefile.complete ├── LICENSE.txt └── README.md /docs/molscript.html: -------------------------------------------------------------------------------- 1 | index.html -------------------------------------------------------------------------------- /docs/_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-minimal -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | papers 2 | *.o 3 | *.a 4 | *~ 5 | molscript 6 | molauto 7 | -------------------------------------------------------------------------------- /docs/images/pdb.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pekrau/MolScript/HEAD/docs/images/pdb.gif -------------------------------------------------------------------------------- /docs/images/sgi.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pekrau/MolScript/HEAD/docs/images/sgi.gif -------------------------------------------------------------------------------- /docs/images/vrml.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pekrau/MolScript/HEAD/docs/images/vrml.gif -------------------------------------------------------------------------------- /examples/ras_cyl.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pekrau/MolScript/HEAD/examples/ras_cyl.gif -------------------------------------------------------------------------------- /examples/ras_cyl.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pekrau/MolScript/HEAD/examples/ras_cyl.jpg -------------------------------------------------------------------------------- /examples/ras_gdp.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pekrau/MolScript/HEAD/examples/ras_gdp.jpg -------------------------------------------------------------------------------- /examples/ras_gdp.rgb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pekrau/MolScript/HEAD/examples/ras_gdp.rgb -------------------------------------------------------------------------------- /examples/ras_std.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pekrau/MolScript/HEAD/examples/ras_std.gif -------------------------------------------------------------------------------- /examples/ras_std.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pekrau/MolScript/HEAD/examples/ras_std.jpg -------------------------------------------------------------------------------- /examples/ras_std.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pekrau/MolScript/HEAD/examples/ras_std.png -------------------------------------------------------------------------------- /examples/ras_std.rgb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pekrau/MolScript/HEAD/examples/ras_std.rgb -------------------------------------------------------------------------------- /examples/ras_std.sgi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pekrau/MolScript/HEAD/examples/ras_std.sgi -------------------------------------------------------------------------------- /docs/images/opengl.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pekrau/MolScript/HEAD/docs/images/opengl.gif -------------------------------------------------------------------------------- /docs/images/ras_cyl.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pekrau/MolScript/HEAD/docs/images/ras_cyl.jpg -------------------------------------------------------------------------------- /docs/images/ras_std.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pekrau/MolScript/HEAD/docs/images/ras_std.jpg -------------------------------------------------------------------------------- /examples/ras_cyl_gz.wrl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pekrau/MolScript/HEAD/examples/ras_cyl_gz.wrl -------------------------------------------------------------------------------- /examples/ras_gdp_gz.wrl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pekrau/MolScript/HEAD/examples/ras_gdp_gz.wrl -------------------------------------------------------------------------------- /examples/ras_rmsd.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pekrau/MolScript/HEAD/examples/ras_rmsd.jpg -------------------------------------------------------------------------------- /examples/ras_rmsd.rgb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pekrau/MolScript/HEAD/examples/ras_rmsd.rgb -------------------------------------------------------------------------------- /examples/ras_rmsd.sgi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pekrau/MolScript/HEAD/examples/ras_rmsd.sgi -------------------------------------------------------------------------------- /examples/ras_shiny.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pekrau/MolScript/HEAD/examples/ras_shiny.jpg -------------------------------------------------------------------------------- /examples/ras_shiny.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pekrau/MolScript/HEAD/examples/ras_shiny.png -------------------------------------------------------------------------------- /examples/ras_shiny.sgi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pekrau/MolScript/HEAD/examples/ras_shiny.sgi -------------------------------------------------------------------------------- /examples/ras_std_gz.wrl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pekrau/MolScript/HEAD/examples/ras_std_gz.wrl -------------------------------------------------------------------------------- /docs/images/coordsys.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pekrau/MolScript/HEAD/docs/images/coordsys.gif -------------------------------------------------------------------------------- /docs/images/gnu_head.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pekrau/MolScript/HEAD/docs/images/gnu_head.gif -------------------------------------------------------------------------------- /docs/images/ras_coil.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pekrau/MolScript/HEAD/docs/images/ras_coil.jpg -------------------------------------------------------------------------------- /docs/images/ras_rmsd.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pekrau/MolScript/HEAD/docs/images/ras_rmsd.jpg -------------------------------------------------------------------------------- /docs/images/ras_shiny.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pekrau/MolScript/HEAD/docs/images/ras_shiny.jpg -------------------------------------------------------------------------------- /docs/images/ras_trace.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pekrau/MolScript/HEAD/docs/images/ras_trace.jpg -------------------------------------------------------------------------------- /docs/images/ras_turn.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pekrau/MolScript/HEAD/docs/images/ras_turn.jpg -------------------------------------------------------------------------------- /docs/images/raster3d.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pekrau/MolScript/HEAD/docs/images/raster3d.gif -------------------------------------------------------------------------------- /examples/ras_gdp_r3d.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pekrau/MolScript/HEAD/examples/ras_gdp_r3d.jpg -------------------------------------------------------------------------------- /examples/ras_molauto.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pekrau/MolScript/HEAD/examples/ras_molauto.jpg -------------------------------------------------------------------------------- /examples/ras_rmsd_r3d.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pekrau/MolScript/HEAD/examples/ras_rmsd_r3d.jpg -------------------------------------------------------------------------------- /examples/ras_std_r3d.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pekrau/MolScript/HEAD/examples/ras_std_r3d.jpg -------------------------------------------------------------------------------- /docs/images/biomedlink.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pekrau/MolScript/HEAD/docs/images/biomedlink.gif -------------------------------------------------------------------------------- /docs/images/ghostscript.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pekrau/MolScript/HEAD/docs/images/ghostscript.gif -------------------------------------------------------------------------------- /docs/images/ras_gdp_cpk.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pekrau/MolScript/HEAD/docs/images/ras_gdp_cpk.jpg -------------------------------------------------------------------------------- /examples/ras_cyl_small.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pekrau/MolScript/HEAD/examples/ras_cyl_small.jpg -------------------------------------------------------------------------------- /examples/ras_gdp_small.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pekrau/MolScript/HEAD/examples/ras_gdp_small.jpg -------------------------------------------------------------------------------- /examples/ras_molauto_gz.wrl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pekrau/MolScript/HEAD/examples/ras_molauto_gz.wrl -------------------------------------------------------------------------------- /examples/ras_rmsd_small.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pekrau/MolScript/HEAD/examples/ras_rmsd_small.jpg -------------------------------------------------------------------------------- /examples/ras_shiny_small.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pekrau/MolScript/HEAD/examples/ras_shiny_small.jpg -------------------------------------------------------------------------------- /examples/ras_std_small.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pekrau/MolScript/HEAD/examples/ras_std_small.jpg -------------------------------------------------------------------------------- /examples/ras_vrml_lod_gz.wrl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pekrau/MolScript/HEAD/examples/ras_vrml_lod_gz.wrl -------------------------------------------------------------------------------- /docs/images/ras_gdp_balls.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pekrau/MolScript/HEAD/docs/images/ras_gdp_balls.jpg -------------------------------------------------------------------------------- /docs/images/ras_gdp_bonds.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pekrau/MolScript/HEAD/docs/images/ras_gdp_bonds.jpg -------------------------------------------------------------------------------- /examples/ras_molauto_nice.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pekrau/MolScript/HEAD/examples/ras_molauto_nice.jpg -------------------------------------------------------------------------------- /examples/ras_molauto_small.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pekrau/MolScript/HEAD/examples/ras_molauto_small.jpg -------------------------------------------------------------------------------- /examples/ras_molauto_nice_gz.wrl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pekrau/MolScript/HEAD/examples/ras_molauto_nice_gz.wrl -------------------------------------------------------------------------------- /examples/ras_molauto_nice_small.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pekrau/MolScript/HEAD/examples/ras_molauto_nice_small.jpg -------------------------------------------------------------------------------- /docs/kraulis_1991_molscript_j_appl_cryst.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pekrau/MolScript/HEAD/docs/kraulis_1991_molscript_j_appl_cryst.pdf -------------------------------------------------------------------------------- /docs/style.css: -------------------------------------------------------------------------------- 1 | * {font-family: Arial, Helvetica, sans-serif; 2 | font-size: small; } 3 | 4 | body {background-color: white; } 5 | 6 | h1 {font-size: large; } 7 | h2 {font-size: large; } 8 | h3 {font-size: normal; } 9 | -------------------------------------------------------------------------------- /examples/style.css: -------------------------------------------------------------------------------- 1 | * {font-family: Arial, Helvetica, sans-serif; 2 | font-size: small; } 3 | 4 | body {background-color: white; } 5 | 6 | h1 {font-size: large; } 7 | h2 {font-size: large; } 8 | h3 {font-size: normal; } 9 | -------------------------------------------------------------------------------- /code/clib/ogl_bitmap_character.h: -------------------------------------------------------------------------------- 1 | #ifndef OGL_BITMAP_CHARACTER_H 2 | #define OGL_BITMAP_CHARACTER_H 1 3 | 4 | #include 5 | 6 | void 7 | ogl_bitmap_character (void *font, int c); 8 | 9 | void 10 | ogl_bitmap_string (void *font, char *str); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /code/clib/ogl_utils.h: -------------------------------------------------------------------------------- 1 | #ifndef OGL_UTILS_H 2 | #define OGL_UTILS_H 1 3 | 4 | #include 5 | 6 | boolean 7 | ogl_check_errors (char *msg); 8 | 9 | boolean 10 | ogl_display_mode_not_available (void); 11 | 12 | void 13 | ogl_display_mode_not_available_fatal (void); 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /code/clib/mol3d_secstruc.h: -------------------------------------------------------------------------------- 1 | #ifndef MOL3D_SECSTRUC_H 2 | #define MOL3D_SECSTRUC_H 1 3 | 4 | #include 5 | 6 | void 7 | mol3d_secstruc_initialize (mol3d *mol); 8 | 9 | void 10 | mol3d_secstruc_ca_geom (mol3d *mol); 11 | 12 | boolean 13 | mol3d_secstruc_hbonds (mol3d *mol); 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /code/clib/err.h: -------------------------------------------------------------------------------- 1 | #ifndef ERR_H 2 | #define ERR_H 1 3 | 4 | void 5 | err_set_prefix (const char *new); 6 | 7 | void 8 | err_fatal (const char *msg); 9 | 10 | void 11 | err_message (const char *msg); 12 | 13 | void 14 | err_usage (const char *msg); 15 | 16 | void 17 | err_warning (const char *msg); 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /code/clib/args.h: -------------------------------------------------------------------------------- 1 | #ifndef ARGS_H 2 | #define ARGS_H 1 3 | 4 | extern int args_number; 5 | extern char *args_command; 6 | 7 | void 8 | args_initialize (int argc, char *argv[]); 9 | 10 | void 11 | args_flag (int number); 12 | 13 | int 14 | args_unflagged (void); 15 | 16 | int 17 | args_exists (char *arg); 18 | 19 | char * 20 | args_item (int number); 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /code/clib/hermite_curve.h: -------------------------------------------------------------------------------- 1 | #ifndef HERMITE_CURVE_H 2 | #define HERMITE_CURVE_H 1 3 | 4 | #include 5 | 6 | void 7 | hermite_set (vector3 *pos_start, vector3 *pos_finish, 8 | vector3 *vec_start, vector3 *vec_finish); 9 | 10 | void 11 | hermite_get (vector3 *p, double t); 12 | 13 | void 14 | hermite_get_tangent (vector3 *v, double t); 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /code/clib/boolean.h: -------------------------------------------------------------------------------- 1 | /* 2 | Boolean constants and typedef. 3 | 4 | clib v1.0 5 | 6 | Copyright (C) 1997 Per Kraulis 7 | 29-Jan-1997 split out of MolScript 8 | */ 9 | 10 | #ifndef BOOLEAN_H 11 | #define BOOLEAN_H 1 12 | 13 | #ifndef FALSE 14 | #define FALSE 0 15 | #endif 16 | 17 | #ifndef TRUE 18 | #define TRUE 1 19 | #endif 20 | 21 | typedef int boolean; 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /code/clib/body3d.h: -------------------------------------------------------------------------------- 1 | #ifndef BODY3D_H 2 | #define BODY3D_H 1 3 | 4 | #include 5 | 6 | vector3 * 7 | sphere_ico_points (int level); 8 | 9 | int 10 | sphere_ico_point_count (int level); 11 | 12 | vector3 * 13 | tetrahedron_vertices (void); 14 | 15 | vector3 * 16 | octahedron_vertices (void); 17 | 18 | vector3 * 19 | cube_vertices (void); 20 | 21 | vector3 * 22 | icosahedron_vertices (void); 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /code/clib/io_utils.h: -------------------------------------------------------------------------------- 1 | #ifndef IO_UTILS_H 2 | #define IO_UTILS_H 1 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | 9 | boolean 10 | io_fprint_str (FILE *file, const char *str); 11 | 12 | boolean 13 | io_fprint_str_length (FILE *file, const char *str, int length); 14 | 15 | boolean 16 | io_fprint_blanks (FILE *file, int count); 17 | 18 | boolean 19 | io_fget_ds (FILE *file, dynstring *ds); 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /code/sgi_img.h: -------------------------------------------------------------------------------- 1 | /* sgi_img.h 2 | 3 | MolScript v2.1.2 4 | 5 | SGI image file. 6 | 7 | This implementation relies on the 'image.c' code, and therefore 8 | implicitly on OpenGL and GLX. 9 | 10 | Copyright (C) 1997-1998 Per Kraulis 11 | 11-Sep-1997 working 12 | */ 13 | 14 | #ifndef SGI_IMG_H 15 | #define SGI_IMG_H 1 16 | 17 | void sgii_set (void); 18 | void sgii_first_plot (void); 19 | void sgii_finish_output (void); 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /examples/ras_gdp_cpk.in: -------------------------------------------------------------------------------- 1 | ! MolScript v2.1 input file 2 | 3 | ! GDP using cpk. 4 | 5 | title "GDP cpk" 6 | 7 | plot 8 | 9 | window 16; 10 | 11 | read mol "ras.pdb"; 12 | 13 | transform atom * 14 | by centre position in residue 200 15 | by rotation 16 | -0.746436 -0.361124 0.558947 17 | 0.235416 0.64233 0.729378 18 | -0.622425 0.676019 -0.394444 19 | ; 20 | 21 | cpk in residue 200; 22 | 23 | end_plot 24 | -------------------------------------------------------------------------------- /docs/license.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | MolScript v2.1: Open Source License 4 | 5 | 6 | 7 | 8 | 9 |

Open Source License

10 | 11 |

12 | The MolScript program is Open Source as of 1 Nov 2014. It is available 13 | under the MIT license. 14 |

15 | 16 |
17 | Top page 18 | 19 | 20 | -------------------------------------------------------------------------------- /code/clib/angle.h: -------------------------------------------------------------------------------- 1 | /* angle.h 2 | 3 | Angle constants 4 | 5 | clib v1.0 6 | 7 | Copyright (C) 1997 Per Kraulis 8 | 29-Jan-1997 split out of MolScript 9 | 3-Dec-1997 changed PI to ANGLE_PI to avoid clashes 10 | */ 11 | 12 | #ifndef ANGLE_H 13 | #define ANGLE_H 1 14 | 15 | #define ANGLE_PI 3.14159265358979323846 16 | 17 | #define to_radians(d) ((d)*ANGLE_PI/180.0) 18 | #define to_degrees(d) ((d)*180.0/ANGLE_PI) 19 | 20 | #define SQRT2 1.4142136 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /examples/ras_gdp_balls.in: -------------------------------------------------------------------------------- 1 | ! MolScript v2.1 input file 2 | 3 | ! GDP using ball-and-stick. 4 | 5 | title "GDP ball-and-stick" 6 | 7 | plot 8 | 9 | window 16; 10 | 11 | read mol "ras.pdb"; 12 | 13 | transform atom * 14 | by centre position in residue 200 15 | by rotation 16 | -0.746436 -0.361124 0.558947 17 | 0.235416 0.64233 0.729378 18 | -0.622425 0.676019 -0.394444 19 | ; 20 | 21 | ball-and-stick in residue 200; 22 | 23 | end_plot 24 | -------------------------------------------------------------------------------- /code/image.h: -------------------------------------------------------------------------------- 1 | /* image.h 2 | 3 | MolScript v2.1.2 4 | 5 | Image file output definitions and routines. 6 | 7 | This implementation requires OpenGL, GLX (X windowing system) and 8 | the GLUT library. It relies on the 'opengl.c' code. 9 | 10 | Copyright (C) 1997-1998 Per Kraulis 11 | 11-Sep-1997 split out of jpeg.h 12 | */ 13 | 14 | #ifndef IMAGE_H 15 | #define IMAGE_H 1 16 | 17 | void image_first_plot (void); 18 | void image_render (void); 19 | void image_close (void); 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /code/clib/mol3d_chain.h: -------------------------------------------------------------------------------- 1 | #ifndef MOL3D_CHAIN_H 2 | #define MOL3D_CHAIN_H 1 3 | 4 | #include 5 | #include 6 | 7 | typedef struct s_mol3d_chain mol3d_chain; 8 | 9 | struct s_mol3d_chain { 10 | int length; 11 | res3d **residues; 12 | at3d **atoms; 13 | mol3d_chain *next; 14 | }; 15 | 16 | mol3d_chain * 17 | mol3d_chain_find (mol3d *first_mol, char *atomname, 18 | double cutoff, int *res_sel); 19 | 20 | void 21 | mol3d_chain_delete (mol3d_chain *first_ch); 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /examples/ras_frames.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | MolScript v2.1: Ras p21 VRML example 4 | 5 | 6 | 7 | 8 | 9 | 10 | Sorry, this document requires a frames-enabled HTML browser. 11 | <br> 12 | Use the non-frames organization instead to view these VRML files. 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /examples/ras_gdp_bonds.in: -------------------------------------------------------------------------------- 1 | ! MolScript v2.1 input file 2 | 3 | ! GDP using bonds. 4 | 5 | title "GDP bonds" 6 | 7 | plot 8 | 9 | window 16; 10 | 11 | read mol "ras.pdb"; 12 | 13 | transform atom * 14 | by centre position in residue 200 15 | by rotation 16 | -0.746436 -0.361124 0.558947 17 | 0.235416 0.64233 0.729378 18 | -0.622425 0.676019 -0.394444 19 | ; 20 | 21 | set colourparts on, 22 | linewidth 2; 23 | 24 | bonds in residue 200; 25 | 26 | end_plot 27 | -------------------------------------------------------------------------------- /code/eps_img.h: -------------------------------------------------------------------------------- 1 | /* eps_img.h 2 | 3 | MolScript v2.1.2 4 | 5 | Encapsulated PostScript (EPS) image file. 6 | 7 | This implementation relies on the 'image.c' code, and therefore 8 | implicitly on OpenGL and GLX. 9 | 10 | Copyright (C) 1997-1998 Per Kraulis 11 | 13-Sep-1997 working 12 | */ 13 | 14 | #ifndef EPS_IMG_H 15 | #define EPS_IMG_H 1 16 | 17 | void eps_set (void); 18 | void eps_first_plot (void); 19 | void eps_finish_output (void); 20 | void eps_set_bw (void); 21 | void eps_set_scale (float new); 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /examples/ras_coil.in: -------------------------------------------------------------------------------- 1 | ! MolScript v2.1 input file 2 | 3 | ! Show coil. 4 | 5 | title "c-H-ras p21 protein (1-166), complex with GDP and Mg" 6 | 7 | plot 8 | 9 | window 40; 10 | 11 | read mol "ras.pdb"; 12 | 13 | transform atom * 14 | by centre position atom * 15 | by rotation 16 | 0.450861 0.724522 -0.521337 17 | 0.328525 0.408374 0.851647 18 | 0.829937 -0.555246 -0.0539039 19 | by translation -2 1 0 20 | ; 21 | 22 | set planecolour green; 23 | coil from 1 to 166; 24 | 25 | end_plot 26 | -------------------------------------------------------------------------------- /examples/ras_trace.in: -------------------------------------------------------------------------------- 1 | ! MolScript v2.1 input file 2 | 3 | ! Show trace. 4 | 5 | title "c-H-ras p21 protein (1-166), complex with GDP and Mg" 6 | 7 | plot 8 | 9 | window 20; 10 | 11 | read mol "ras.pdb"; 12 | 13 | transform atom * 14 | by centre position atom * 15 | by rotation 16 | 0.450861 0.724522 -0.521337 17 | 0.328525 0.408374 0.851647 18 | 0.829937 -0.555246 -0.0539039 19 | by translation -2 -8 0 20 | ; 21 | 22 | set linecolour red; 23 | trace from 1 to 166; 24 | 25 | end_plot 26 | -------------------------------------------------------------------------------- /examples/ras_turn.in: -------------------------------------------------------------------------------- 1 | ! MolScript v2.1 input file 2 | 3 | ! Show turn. 4 | 5 | title "c-H-ras p21 protein (1-166), complex with GDP and Mg" 6 | 7 | plot 8 | 9 | window 40; 10 | 11 | read mol "ras.pdb"; 12 | 13 | transform atom * 14 | by centre position atom * 15 | by rotation 16 | 0.450861 0.724522 -0.521337 17 | 0.328525 0.408374 0.851647 18 | 0.829937 -0.555246 -0.0539039 19 | by translation -2 1 0 20 | ; 21 | 22 | set planecolour cyan; 23 | turn from 1 to 166; 24 | 25 | end_plot 26 | -------------------------------------------------------------------------------- /code/png_img.h: -------------------------------------------------------------------------------- 1 | /* png_img.h 2 | 3 | MolScript v2.1.2 4 | 5 | PNG image file. 6 | 7 | This implementation is based on the PNG Reference Library 1.0 8 | version 0.96 and zlib v1.0.4. It relies on the 'image.c' code, 9 | and therefore implicitly on OpenGL and GLX. 10 | 11 | Copyright (C) 1997-1998 Per Kraulis 12 | 12-Sep-1997 started 13 | */ 14 | 15 | #ifndef PNG_IMG_H 16 | #define PNG_IMG_H 1 17 | 18 | void pngi_set (void); 19 | void pngi_first_plot (void); 20 | void pngi_finish_output (void); 21 | int pngi_set_compression (char *level); 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /code/clib/element_lookup.h: -------------------------------------------------------------------------------- 1 | /* element_lookup.h 2 | 3 | Chemical element symbol lookup. 4 | 5 | clib v1.1 6 | 7 | Copyright (C) 1998 Per Kraulis 8 | 2-Mar-1998 first attempts 9 | 4-Mar-1998 written 10 | */ 11 | 12 | #ifndef ELEMENT_LOOKUP_H 13 | #define ELEMENT_LOOKUP_H 1 14 | 15 | #include 16 | 17 | extern const int element_max_number; 18 | 19 | int element_number (const char *symbol); 20 | int element_number_convert (const char *symbol); 21 | int element_valid_number (int number); 22 | char *element_symbol (int element_number); 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /examples/ras_mg_text.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Ras p21: Mg ion 4 | 5 | 6 | 7 | 8 | 9 |

Mg ion

10 |

11 | A magnesium (Mg) ion is a required constituent of the catalytically 12 | competent enzyme, and seems to be present in all physiologically 13 | relevant forms of the protein. It is possible to substitute in 14 | vitro the Mg for certain other divalent metal ions, such as 15 | manganese (Mn). 16 |

17 | 18 | Top page 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /code/clib/key_value.h: -------------------------------------------------------------------------------- 1 | #ifndef KEY_VALUE_H 2 | #define KEY_VALUE_H 1 3 | 4 | #include 5 | 6 | typedef struct s_key_value key_value; 7 | 8 | struct s_key_value { 9 | dynstring *key; 10 | dynstring *value; 11 | key_value *next; 12 | }; 13 | 14 | key_value * 15 | kv_create (const char *k, const char *v); 16 | 17 | void 18 | kv_delete (key_value *kv); 19 | 20 | key_value * 21 | kv_append (key_value *kv, key_value *new); 22 | 23 | key_value * 24 | kv_search (key_value *first, const char *key); 25 | 26 | char * 27 | kv_search_value_str (key_value *first, char *key); 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /code/jpeg_img.h: -------------------------------------------------------------------------------- 1 | /* jpeg_img.h 2 | 3 | MolScript v2.1.2 4 | 5 | JPEG image file. 6 | 7 | This implementation is based on the Independent JPEG Group's (IJG) 8 | JPEG library (release 6a). It relies on the 'image.c' code, and 9 | therefore implicitly on OpenGL and GLX. 10 | 11 | Copyright (C) 1997-1998 Per Kraulis 12 | 9-Sep-1997 started 13 | 11-Sep-1997 working 14 | */ 15 | 16 | #ifndef JPEG_IMG_H 17 | #define JPEG_IMG_H 1 18 | 19 | void jpgi_set (void); 20 | void jpgi_first_plot (void); 21 | void jpgi_finish_output (void); 22 | void jpgi_set_quality (int new); 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /code/clib/extent3d.h: -------------------------------------------------------------------------------- 1 | #ifndef EXTENT3D_H 2 | #define EXTENT3D_H 1 3 | 4 | #include 5 | #include 6 | 7 | void 8 | ext3d_initialize (void); 9 | 10 | void 11 | ext3d_push (void); 12 | 13 | void 14 | ext3d_pop (boolean transfer); 15 | 16 | int 17 | ext3d_depth (void); 18 | 19 | void 20 | ext3d_get_center_size (vector3 *center, vector3 *size); 21 | 22 | void 23 | ext3d_get_low_high (vector3 *low, vector3 *high); 24 | 25 | void 26 | ext3d_set_center_size (vector3 *center, vector3 *size); 27 | 28 | void 29 | ext3d_set_low_high (vector3 *low, vector3 *high); 30 | 31 | void 32 | ext3d_update (vector3 *p, double radius); 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /code/gif_img.h: -------------------------------------------------------------------------------- 1 | /* gif_img.h 2 | 3 | MolScript v2.1.2 4 | 5 | GIF image file. 6 | 7 | This implementation uses the gd 1.3 library by Thomas Boutell, 8 | http://www.boutell.com. The source code for this library does *not* 9 | use LZW compression, so there is no conflict with the (infamous) 10 | Unisys patent on the LZW algorithm. This implementation relies on 11 | the 'image.c' code, and therefore implicitly on OpenGL and GLX. 12 | 13 | Copyright (C) 1998 Per Kraulis 14 | 29-Jul-1998 first attempts 15 | */ 16 | 17 | #ifndef GIF_IMG_H 18 | #define GIF_IMG_H 1 19 | 20 | void gifi_set (void); 21 | void gifi_first_plot (void); 22 | void gifi_finish_output (void); 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /code/lex.h: -------------------------------------------------------------------------------- 1 | /* lex.h 2 | 3 | MolScript v2.1.2 4 | 5 | Input lexer. 6 | 7 | Copyright (C) 1997-1998 Per Kraulis 8 | 14-Dec-1996 first attempts 9 | 1-Aug-1997 cleanup procedure 10 | 15-Jan-1998 added yytext stack 11 | */ 12 | 13 | #ifndef LEX_H 14 | #define LEX_H 1 15 | 16 | #include 17 | 18 | extern char yytext[]; 19 | extern int yylen; 20 | 21 | void lex_init (void); 22 | void lex_info (void); 23 | void lex_cleanup (void); 24 | void lex_set_input_file (const char *filename); 25 | FILE *lex_input_file (void); 26 | void lex_define_macro (char *name); 27 | void lex_yytext_push (void); 28 | void lex_yytext_pop (void); 29 | int lex_yytext_depth (void); 30 | char *lex_yytext_str (void); 31 | 32 | int yylex (void); 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /examples/ras_loops_text.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Ras p21: Effector loops 4 | 5 | 6 | 7 | 8 | 9 |

Effector loops

10 |

11 | The two long loops closest to the Mg ion display the largest 12 | conformational differences when comparing the GDP and GTP forms of ras 13 | p21. These loops are also the most variable, as illustrated 14 | in this VRML model, 15 | where the colours indicate variability (blue=well-defined, 16 | red=variable). These loops are the main sites of interactions with 17 | other proteins, such as SOS and rasGAP. 18 |

19 | 20 | Top page 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /examples/ras_gdp_text.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Ras p21: GDP molecule 4 | 5 | 6 | 7 | 8 | 9 |

GDP molecule

10 |

11 | The GDP molecule consists of three moieties: The guanine ring, which 12 | is a nitrogen-containing heterocycle; the ribose sugar ring; and the 13 | diphosphate group, with purple atoms being phosphorus. The 14 | abbreviation GDP stands for guanosine diphosphate. The active, "on" form 15 | of the ras protein contains the triphosphate (GTP), which is 16 | hydrolysed to the diphosphate by the enzyme. This reaction is much 17 | enhanced by interactions with Ras-GAP. 18 |

19 | 20 | Top page 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /code/clib/mol3d_init.h: -------------------------------------------------------------------------------- 1 | #ifndef MOL3D_INIT_H 2 | #define MOL3D_INIT_H 1 3 | 4 | #include 5 | 6 | void 7 | mol3d_init (mol3d *mol, unsigned int flags); 8 | 9 | void 10 | mol3d_init_noblanks (mol3d *mol); 11 | 12 | void 13 | mol3d_init_colours (mol3d *mol); 14 | 15 | void 16 | mol3d_init_radii (mol3d *mol); 17 | 18 | void 19 | mol3d_init_aacodes (mol3d *mol); 20 | 21 | void 22 | mol3d_init_centrals (mol3d *mol, const char *atomname); 23 | 24 | void 25 | mol3d_init_centrals_protein (mol3d *mol); 26 | 27 | void 28 | mol3d_init_residue_ordinals (mol3d *mol, int start); 29 | 30 | void 31 | mol3d_init_residue_ordinals_protein (mol3d *mol); 32 | 33 | void 34 | mol3d_init_atom_ordinals (mol3d *mol, int start); 35 | 36 | void 37 | mol3d_init_elements (mol3d *mol); 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /code/xform.h: -------------------------------------------------------------------------------- 1 | /* xform.h 2 | 3 | MolScript v2.1.2 4 | 5 | Coordinate transformation. 6 | 7 | Copyright (C) 1997-1998 Per Kraulis 8 | 6-Apr-1997 split out of coord.h 9 | 23-Jun-1997 added axis rotation 10 | */ 11 | 12 | #ifndef XFORM_H 13 | #define XFORM_H 1 14 | 15 | #include "clib/mol3d.h" 16 | 17 | extern double xform[4][4]; 18 | 19 | void xform_init (void); 20 | void xform_init_stored (void); 21 | void xform_store (void); 22 | 23 | void xform_centre (void); 24 | void xform_translation (void); 25 | void xform_rotation_x (void); 26 | void xform_rotation_y (void); 27 | void xform_rotation_z (void); 28 | void xform_rotation_axis (void); 29 | void xform_rotation_matrix (void); 30 | void xform_recall_matrix (void); 31 | 32 | void xform_atoms (void); 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /code/clib/quaternion.h: -------------------------------------------------------------------------------- 1 | #ifndef QUATERNION_H 2 | #define QUATERNION_H 1 3 | 4 | #include 5 | #include 6 | 7 | typedef struct { 8 | vector3 axis; 9 | double phi; 10 | } quaternion; 11 | 12 | void 13 | quat_initialize (quaternion *q, double x, double y, double z, double phi); 14 | 15 | void 16 | quat_initialize_v3 (quaternion *q, vector3 *v, double phi); 17 | 18 | void 19 | quat_normalize (quaternion *q); 20 | 21 | void 22 | quat_add (quaternion *dest, quaternion *incr); 23 | 24 | void 25 | quat_to_matrix3 (double m[4][4], quaternion *q); 26 | 27 | void 28 | quat_interpolate (quaternion *dest, quaternion *q0, quaternion *q1, double t); 29 | 30 | void 31 | quat_trackball (quaternion *dest, double size, 32 | double p1x, double p1y, double p2x, double p2y); 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /code/clib/named_data.h: -------------------------------------------------------------------------------- 1 | #ifndef NAMED_DATA_H 2 | #define NAMED_DATA_H 1 3 | 4 | #include 5 | 6 | #include 7 | 8 | typedef struct _named_data named_data; 9 | 10 | struct _named_data { 11 | char *name; 12 | void *data; 13 | boolean name_copy, data_copy; 14 | named_data *next; 15 | }; 16 | 17 | named_data * 18 | nd_create (char *name, boolean copy); 19 | 20 | named_data * 21 | nd_set_data (named_data *nd, void *data, boolean copy); 22 | 23 | named_data * 24 | nd_set_data_clone (named_data *nd, void *data, size_t size); 25 | 26 | void 27 | nd_delete (named_data *nd); 28 | 29 | named_data * 30 | nd_append (named_data *nd, named_data *new); 31 | 32 | named_data * 33 | nd_search (named_data *nd, const char *name); 34 | 35 | void * 36 | nd_search_data (named_data *nd, const char *name); 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /code/col.h: -------------------------------------------------------------------------------- 1 | /* col.h 2 | 3 | MolScript v2.1.2 4 | 5 | Colour routine definitions. 6 | 7 | Copyright (C) 1997-1998 Per Kraulis 8 | 4-Dec-1996 first attempts 9 | 29-Jan-1997 use clib colour 10 | */ 11 | 12 | #ifndef COL_H 13 | #define COL_H 1 14 | 15 | #include "clib/colour.h" 16 | 17 | extern colour given_colour; 18 | extern colour white_colour, black_colour, grey_colour, grey02_colour, 19 | red_colour, blue_colour; 20 | extern colour ramp_from_colour, ramp_to_colour; 21 | 22 | void constant_colours_to_rgb (void); 23 | int invalid_colour (colour *c); 24 | void set_rgb (void); 25 | void set_hsb (void); 26 | void set_grey (void); 27 | void set_colour (const char *name); 28 | 29 | void set_colour_ramp (colour *ramp_to); 30 | void set_rainbow_ramp (void); 31 | void ramp_colour (colour *dest, double f); 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /code/clib/mol3d_io.h: -------------------------------------------------------------------------------- 1 | #ifndef MOL3D_IO_H 2 | #define MOL3D_IO_H 1 3 | 4 | #include 5 | 6 | #include 7 | 8 | enum mol3d_file_types { MOL3D_UNKNOWN_FILE, MOL3D_PDB_FILE, MOL3D_MSA_FILE, 9 | MOL3D_DG_FILE, MOL3D_RD_FILE, MOL3D_CDS_FILE, 10 | MOL3D_WAH_FILE }; 11 | 12 | int 13 | mol3d_file_type (char *filename); 14 | 15 | boolean 16 | mol3d_file_is_pdb (FILE *file); 17 | 18 | mol3d * 19 | mol3d_read_pdb_file (FILE *file); 20 | 21 | mol3d * 22 | mol3d_read_pdb_filename (char *filename); 23 | 24 | boolean 25 | mol3d_is_pdb_code (char *code); 26 | 27 | mol3d * 28 | mol3d_read_pdb_code (char *code); 29 | 30 | boolean 31 | mol3d_write_pdb_file (FILE *file, mol3d *first_mol); 32 | 33 | boolean 34 | mol3d_write_pdb_header (FILE *file, mol3d *mol); 35 | 36 | int 37 | mol3d_write_pdb_file_mol (FILE *file, mol3d *mol); 38 | 39 | boolean 40 | mol3d_write_pdb_filename (char *filename, mol3d *first_mol); 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /code/postscript.h: -------------------------------------------------------------------------------- 1 | /* postscript.h 2 | 3 | MolScript v2.1.2 4 | 5 | PostScript file. 6 | 7 | Copyright (C) 1997-1998 Per Kraulis 8 | 4-Dec-1996 first attempts 9 | */ 10 | 11 | #ifndef POSTSCRIPT_H 12 | #define POSTSCRIPT_H 1 13 | 14 | #include "coord.h" 15 | 16 | void ps_set (void); 17 | 18 | void ps_first_plot (void); 19 | void ps_finish_output (void); 20 | void ps_start_plot (void); 21 | void ps_finish_plot (void); 22 | 23 | void ps_set_eps (void); 24 | void ps_set_background (void); 25 | void ps_set_area (void); 26 | 27 | void ps_coil (void); 28 | void ps_cylinder (vector3 *v1, vector3 *v2); 29 | void ps_helix (void); 30 | void ps_label (vector3 *p, char *label, colour *c); 31 | void ps_line (boolean polylines); 32 | void ps_stick (vector3 *v1, vector3 *v2, double r1, double r2, colour *c); 33 | void ps_sphere (at3d *at, double radius); 34 | void ps_strand (void); 35 | 36 | void ps_object (int code, vector3 *triplets, int count); 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /code/other/glutstroke.h: -------------------------------------------------------------------------------- 1 | #ifndef __glutstroke_h__ 2 | #define __glutstroke_h__ 3 | 4 | /* Copyright (c) Mark J. Kilgard, 1994. */ 5 | 6 | /* This program is freely distributable without licensing fees 7 | and is provided without guarantee or warrantee expressed or 8 | implied. This program is -not- in the public domain. */ 9 | 10 | #if defined(WIN32) 11 | #pragma warning (disable:4244) 12 | #endif 13 | 14 | typedef struct { 15 | float x; 16 | float y; 17 | } CoordRec, *CoordPtr; 18 | 19 | typedef struct { 20 | int num_coords; 21 | const CoordRec *coord; 22 | } StrokeRec, *StrokePtr; 23 | 24 | typedef struct { 25 | int num_strokes; 26 | const StrokeRec *stroke; 27 | float center; 28 | float right; 29 | } StrokeCharRec, *StrokeCharPtr; 30 | 31 | typedef struct { 32 | const char *name; 33 | int num_chars; 34 | const StrokeCharRec *ch; 35 | float top; 36 | float bottom; 37 | } StrokeFontRec, *StrokeFontPtr; 38 | 39 | typedef void *GLUTstrokeFont; 40 | 41 | #endif /* __glutstroke_h__ */ 42 | -------------------------------------------------------------------------------- /code/clib/indent.h: -------------------------------------------------------------------------------- 1 | #ifndef INDENT_H 2 | #define INDENT_H 1 3 | 4 | #include 5 | 6 | #include 7 | 8 | #define INDENT_FPRINTF indent_buflen+=fprintf 9 | 10 | extern FILE *indent_file; 11 | extern boolean indent_flag; 12 | extern int indent_level; 13 | extern int indent_increment; 14 | extern boolean indent_needs_blank; 15 | extern int indent_buflen; 16 | extern int indent_max_buflen; 17 | 18 | void 19 | indent_initialize (FILE *file); 20 | 21 | boolean 22 | indent_valid_state (void); 23 | 24 | void 25 | indent_putchar (char c); 26 | 27 | void 28 | indent_string (char *str); 29 | 30 | void 31 | indent_blank (void); 32 | 33 | void 34 | indent_newline (void); 35 | 36 | void 37 | indent_newline_conditional (void); 38 | 39 | void 40 | indent_check_buflen (int additional); 41 | 42 | void 43 | indent_set_indent (boolean on); 44 | 45 | void 46 | indent_set_level (int new); 47 | 48 | void 49 | indent_set_max_buflen (int new); 50 | 51 | void 52 | indent_increment_level (boolean incr); 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /code/clib/str_utils.h: -------------------------------------------------------------------------------- 1 | #ifndef STR_UTILS_H 2 | #define STR_UTILS_H 1 3 | 4 | #include 5 | 6 | boolean 7 | str_eq (const char *str1, const char *str2); 8 | 9 | boolean 10 | str_eqn (const char *str1, const char *str2, const int n); 11 | 12 | boolean 13 | str_eq_min (const char *str1, const char *str2); 14 | 15 | void 16 | str_fill_blanks (char *str, int const length); 17 | 18 | void 19 | str_remove_blanks (char *str); 20 | 21 | void 22 | str_remove_nulls (char *str, int const length); 23 | 24 | void 25 | str_left_adjust (char *str); 26 | 27 | void 28 | str_right_adjust (char *str); 29 | 30 | void 31 | str_exchange (char *str, char old, char new); 32 | 33 | void 34 | str_upcase (char *str); 35 | 36 | void 37 | str_lowcase (char *str); 38 | 39 | char * 40 | str_alloc (const int length); 41 | 42 | char * 43 | str_clone (const char *str); 44 | 45 | char * 46 | str_subclone (const char *str, const int first, const int last); 47 | 48 | int 49 | str_hashcode (const char *str, const int range); 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /examples/ras_molauto_nice.in: -------------------------------------------------------------------------------- 1 | ! MolScript v2.1 input file 2 | ! generated by MolAuto v1.1 3 | 4 | title "C-H-RAS P21 PROTEIN (CATALYTIC DOMAIN, RESIDUES 1 - 166) COMPLEXED WITH GDP AND MG (NMR, RESTRAINED MINIMIZED AVERAGE)" 5 | 6 | plot 7 | 8 | read mol "ras.pdb"; 9 | 10 | transform atom * by centre position atom *; 11 | 12 | set colourparts on, residuecolour amino-acids rainbow; 13 | 14 | coil from 1 to 2; 15 | strand from 2 to 9; 16 | coil from 9 to 15; 17 | helix from 15 to 25; 18 | coil from 25 to 38; 19 | strand from 38 to 46; 20 | coil from 46 to 49; 21 | strand from 49 to 57; 22 | coil from 57 to 66; 23 | helix from 66 to 75; 24 | coil from 75 to 77; 25 | strand from 77 to 84; 26 | coil from 84 to 87; 27 | helix from 87 to 104; 28 | coil from 104 to 110; 29 | strand from 110 to 117; 30 | coil from 117 to 127; 31 | helix from 127 to 138; 32 | coil from 138 to 152; 33 | helix from 152 to 166; 34 | 35 | set colourparts on; 36 | cpk in residue 200; 37 | cpk in residue 201; 38 | 39 | end_plot 40 | -------------------------------------------------------------------------------- /code/clib/mol3d_utils.h: -------------------------------------------------------------------------------- 1 | #ifndef MOL3D_UTILS_H 2 | #define MOL3D_UTILS_H 1 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | 9 | void 10 | mol3d_fprintf_count (FILE *file, mol3d *mol); 11 | 12 | void 13 | mol3d_fprintf_count_all (FILE *file, mol3d *first_mol); 14 | 15 | void 16 | mol3d_fprintf_residues (FILE *file, mol3d *mol); 17 | 18 | at3d ** 19 | mol3d_atom_list (mol3d *mol); 20 | 21 | at3d ** 22 | mol3d_atom_list_all (mol3d *first_mol); 23 | 24 | res3d ** 25 | mol3d_residue_list (mol3d *mol); 26 | 27 | res3d ** 28 | mol3d_residue_list_all (mol3d *first_mol); 29 | 30 | int 31 | mol3d_delete_altloc_atoms (mol3d *mol); 32 | 33 | int 34 | mol3d_delete_residue_type (mol3d *mol, char *type); 35 | 36 | void 37 | mol3d_extent (mol3d *mol, vector3 *low, vector3 *high); 38 | 39 | double 40 | mol3d_max_radius (mol3d *mol); 41 | 42 | boolean 43 | res3d_unique_name (mol3d *mol, res3d *res); 44 | 45 | res3d * 46 | res3d_find_aa_number (mol3d *mol, int number); 47 | 48 | int 49 | res3d_aa_number (mol3d *mol, res3d *res); 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /code/clib/matrix3.h: -------------------------------------------------------------------------------- 1 | #ifndef MATRIX3_H 2 | #define MATRIX3_H 1 3 | 4 | #include 5 | 6 | void 7 | matrix3_initialize (double m[4][4]); 8 | 9 | void 10 | matrix3_copy (double dest[4][4], double src[4][4]); 11 | 12 | void 13 | matrix3_concatenate (double dest[4][4], double src[4][4]); 14 | 15 | void 16 | matrix3_x_rotation (double m[4][4], double radians); 17 | 18 | void 19 | matrix3_y_rotation (double m[4][4], double radians); 20 | 21 | void 22 | matrix3_z_rotation (double m[4][4], double radians); 23 | 24 | void 25 | matrix3_translation (double m[4][4], double x, double y, double z); 26 | 27 | void 28 | matrix3_scale (double m[4][4], double sx, double sy, double sz); 29 | 30 | void 31 | matrix3_orthographic_projection (double m[4][4], 32 | double left, double right, 33 | double bottom, double top, 34 | double near, double far); 35 | 36 | void 37 | matrix3_transform (vector3 *v, double m[4][4]); 38 | 39 | void 40 | matrix3_rotate (vector3 *v, double m[4][4]); 41 | 42 | void 43 | matrix3_rotate_translate (vector3 *v, double m[4][4]); 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /docs/disclaimer.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | MolScript v2.1: Disclaimer 4 | 5 | 6 | 7 | 8 | 9 |

Disclaimer

10 | 11 | The material embodied in this software is provided to you "as-is" and 12 | without warranty of any kind, express, implied or otherwise, including 13 | without limitation, any warranty of fitness for a particular 14 | purpose. In no event shall Avatar Software AB be liable to you or 15 | anyone else for any direct, special, incidental, indirect or 16 | consequential damages of any kind, or any damages whatsoever, 17 | including without limitation, loss of profit, loss of use, savings or 18 | revenue, or the claims of third parties, whether or not Avatar 19 | Software AB has been advised of the possibility of such loss, however 20 | caused and on any theory of liability, arising out of or in connection 21 | with the possession, use or performance of this software. 22 |

23 | 24 |


25 | Top page 26 | 27 | 28 | -------------------------------------------------------------------------------- /code/coord.h: -------------------------------------------------------------------------------- 1 | /* coord.h 2 | 3 | MolScript v2.1.2 4 | 5 | Coordinate data handling. 6 | 7 | Copyright (C) 1997-1998 Per Kraulis 8 | 4-Dec-1996 first attempts 9 | 3-Jan-1997 fairly finished 10 | 30-Jan-1997 use clib mol3d 11 | */ 12 | 13 | #ifndef COORD_H 14 | #define COORD_H 1 15 | 16 | #include "clib/mol3d_io.h" 17 | #include "clib/mol3d_init.h" 18 | #include "clib/mol3d_chain.h" 19 | 20 | 21 | #define PEPTIDE_CHAIN_ATOMNAME "CA" 22 | #define PEPTIDE_DISTANCE 4.2 23 | #define NUCLEOTIDE_CHAIN_ATOMNAME "P" 24 | #define NUCLEOTIDE_DISTANCE 10.0 25 | 26 | extern mol3d *first_molecule; 27 | extern int total_atoms; 28 | extern int total_residues; 29 | 30 | void store_molname (char *name); 31 | void read_coordinate_file (char *filename); 32 | void init_molecule (mol3d *mol); 33 | void update_totals (void); 34 | 35 | void copy_molecule (char *name); 36 | void delete_molecule (char *name); 37 | void delete_all_molecules (void); 38 | 39 | mol3d_chain *get_peptide_chains (void); 40 | mol3d_chain *get_nucleotide_chains (void); 41 | 42 | void position (void); 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /code/other/regex.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Definitions etc. for regexp(3) routines. 3 | * 4 | * Caveat: this is V8 regexp(3) [actually, a reimplementation thereof], 5 | * not the System V one. 6 | * 7 | * Copyright: see 'regex.c' file. 8 | * 9 | * Per Kraulis 10 | * 29-Jan-1997 converted to ANSI C 11 | * 18-Jun-1997 changed argument tests into assert's 12 | * 17-Sep-1997 added function 'regcomp_pjk', which takes a MolScript-style 13 | * regular expression and compiles it into a 'regexp' 14 | */ 15 | 16 | #ifndef REGEX_H 17 | #define REGEX_H 1 18 | 19 | #define NSUBEXP 10 20 | 21 | typedef struct regexp { 22 | char *startp[NSUBEXP]; 23 | char *endp[NSUBEXP]; 24 | char regstart; /* Internal use only. */ 25 | char reganch; /* Internal use only. */ 26 | char *regmust; /* Internal use only. */ 27 | int regmlen; /* Internal use only. */ 28 | char program[1]; /* Unwarranted chumminess with compiler. */ 29 | } regexp; 30 | 31 | void regerror (char *s); 32 | regexp *regcomp (char *exp); 33 | int regexec (regexp *prog, char *string); 34 | 35 | regexp *regcomp_pjk (const char *str); 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 1997-1998 Per J. Kraulis 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /docs/LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 1997-1998 Per J. Kraulis 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /code/raster3d.h: -------------------------------------------------------------------------------- 1 | /* raster3d.h 2 | 3 | MolScript v2.1.2 4 | 5 | Raster3D; input for the 'render' program. 6 | 7 | Copyright (C) 1997-1998 Per Kraulis 8 | 4-Dec-1996 first attempts 9 | 16-Sep-1997 label output using GLUT stroke character def's 10 | 17-Sep-1997 fairly finished 11 | */ 12 | 13 | #ifndef RASTER3D_H 14 | #define RASTER3D_H 1 15 | 16 | #include "coord.h" 17 | 18 | void r3d_set (void); 19 | 20 | void r3d_first_plot (void); 21 | void r3d_finish_output (void); 22 | void r3d_start_plot (void); 23 | void r3d_finish_plot (void); 24 | 25 | void r3d_set_area (void); 26 | void r3d_set_background (void); 27 | void r3d_directionallight (void); 28 | void r3d_pointlight (void); 29 | void r3d_comment (char *str); 30 | 31 | void r3d_coil (void); 32 | void r3d_cylinder (vector3 *v1, vector3 *v2); 33 | void r3d_helix (void); 34 | void r3d_label (vector3 *p, char *label, colour *c); 35 | void r3d_line (boolean polylines); 36 | void r3d_points (int colours); 37 | void r3d_sphere (at3d *at, double radius); 38 | void r3d_stick (vector3 *v1, vector3 *v2, double r1, double r2, colour *c); 39 | void r3d_strand (void); 40 | 41 | void r3d_object (int code, vector3 *triplets, int count); 42 | 43 | void r3d_set_antialiasing (int new); 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /code/clib/ogl_body.h: -------------------------------------------------------------------------------- 1 | #ifndef OGL_BODY_H 2 | #define OGL_BODY_H 1 3 | 4 | #include 5 | 6 | void 7 | ogl_sphere_vertices_ico (vector3 *pos, double radius, int level); 8 | 9 | void 10 | ogl_sphere_faces_ico_recursive (vector3 *pos, double radius, int depth); 11 | 12 | void 13 | ogl_sphere_faces_globe (vector3 *pos, double radius, int segments); 14 | 15 | void 16 | ogl_tetrahedron_vertices (vector3 *pos, double radius); 17 | 18 | void 19 | ogl_tetrahedron_edges (vector3 *pos, double radius); 20 | 21 | void 22 | ogl_tetrahedron_faces (vector3 *pos, double radius); 23 | 24 | void 25 | ogl_octahedron_vertices (vector3 *pos, double radius); 26 | 27 | void 28 | ogl_octahedron_edges (vector3 *pos, double radius); 29 | 30 | void 31 | ogl_octahedron_faces (vector3 *pos, double radius); 32 | 33 | void 34 | ogl_cube_vertices (vector3 *pos, double radius); 35 | 36 | void 37 | ogl_cube_edges (vector3 *pos, double radius); 38 | 39 | void 40 | ogl_cube_faces (vector3 *pos, double radius); 41 | 42 | void 43 | ogl_icosahedron_vertices (vector3 *pos, double radius); 44 | 45 | void 46 | ogl_icosahedron_edges (vector3 *pos, double radius); 47 | 48 | void 49 | ogl_icosahedron_faces (vector3 *pos, double radius); 50 | 51 | void 52 | ogl_cylinder_faces (vector3 *pos1, vector3 *pos2, 53 | double radius, int segments, boolean capped); 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /code/opengl.h: -------------------------------------------------------------------------------- 1 | /* opengl.h 2 | 3 | MolScript v2.1.2 4 | 5 | OpenGL. 6 | 7 | This implementation requires the GLUT library. 8 | 9 | Copyright (C) 1997-1998 Per Kraulis 10 | 25-Jun-1997 11 | 11-Sep-1997 fairly finished 12 | */ 13 | 14 | #ifndef OPENGL_H 15 | #define OPENGL_H 1 16 | 17 | #include "coord.h" 18 | 19 | void ogl_set (void); 20 | 21 | void ogl_first_plot (void); 22 | void ogl_start_plot (void); 23 | void ogl_finish_plot (void); 24 | 25 | void ogl_start_plot_general (void); 26 | void ogl_render_init (void); 27 | void ogl_render_lights (void); 28 | void ogl_render_lists (void); 29 | 30 | int ogl_accum (void); 31 | void ogl_set_accum (int number); 32 | 33 | void ogl_set_area (void); 34 | void ogl_set_background (void); 35 | void ogl_directionallight (void); 36 | void ogl_pointlight (void); 37 | void ogl_spotlight (void); 38 | 39 | void ogl_coil (void); 40 | void ogl_cylinder (vector3 *v1, vector3 *v2); 41 | void ogl_helix (void); 42 | void ogl_label (vector3 *p, char *label, colour *c); 43 | void ogl_line (boolean polylines); 44 | void ogl_sphere (at3d *at, double radius); 45 | void ogl_stick (vector3 *v1, vector3 *v2, double r1, double r2, colour *c); 46 | void ogl_strand (void); 47 | 48 | void ogl_start_object (void); 49 | void ogl_object (int code, vector3 *triplets, int count); 50 | void ogl_finish_object (void); 51 | 52 | void ogl_pickable (at3d *atom); 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /code/clib/double_hash.h: -------------------------------------------------------------------------------- 1 | /* double_hash.h 2 | 3 | Hash table for objects using string keys, using the double-hashing 4 | scheme. No removal of single entries can be done in this implementation. 5 | 6 | The key and object pointers are assumed to point to memory shared with 7 | other parts of the calling program. No duplication or cleanup of the 8 | memory for these entities is performed by the procedures in this package, 9 | except by the explicit procedure 'dhash_delete_contents'. 10 | 11 | clib v1.0 12 | 13 | Copyright (C) 1997 Per Kraulis 14 | 27-Aug-1997 first attempts 15 | */ 16 | 17 | #ifndef DOUBLE_HASH_H 18 | #define DOUBLE_HASH_H 1 19 | 20 | #include 21 | 22 | typedef struct { 23 | char **keys; 24 | void **objects; 25 | int count; 26 | int size; 27 | double auto_resize; 28 | } dhash_table; 29 | 30 | dhash_table *dhash_create (const int max_entries); 31 | dhash_table *dhash_create_size (const int size); 32 | void dhash_resize (dhash_table *table, const int new); 33 | void dhash_delete (dhash_table *table); 34 | void dhash_delete_contents (dhash_table *table); 35 | 36 | int dhash_insert (dhash_table *table, char *key, void *object); 37 | void dhash_insert_replace (dhash_table *table, char *key, void *object); 38 | 39 | int dhash_slot (const dhash_table *table, const char *key); 40 | void *dhash_object (const dhash_table *table, const char *key); 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /code/clib/colour.h: -------------------------------------------------------------------------------- 1 | #ifndef COLOUR_H 2 | #define COLOUR_H 1 3 | 4 | #include 5 | 6 | enum colour_spec_codes { COLOUR_RGB = 0, COLOUR_HSB, COLOUR_GREY }; 7 | 8 | typedef struct { 9 | int spec; 10 | double x, y ,z; 11 | } colour; 12 | 13 | int 14 | colour_names_count (void); 15 | 16 | void 17 | colour_name (char *name, colour *c, int number); 18 | 19 | boolean 20 | colour_set_name (colour *c, const char *name); 21 | 22 | void 23 | colour_set_rgb (colour *c, double r, double g, double b); 24 | 25 | void 26 | colour_set_hsb (colour *c, double h, double s, double b); 27 | 28 | void 29 | colour_set_grey (colour *c, double g); 30 | 31 | void 32 | colour_to_rgb (colour *c); 33 | 34 | void 35 | colour_to_hsb (colour *c); 36 | 37 | void 38 | colour_to_grey (colour *c); 39 | 40 | void 41 | colour_copy_to_rgb (colour *dest, colour *src); 42 | 43 | void 44 | colour_copy_to_hsb (colour *dest, colour *src); 45 | 46 | void 47 | colour_copy_to_grey (colour *dest, colour *src); 48 | 49 | colour * 50 | colour_clone (colour *c); 51 | 52 | boolean 53 | colour_approx_equal (const colour *c1, const colour *c2, double maxdiff); 54 | 55 | boolean 56 | colour_unequal (const colour *c1, const colour *c2); 57 | 58 | void 59 | colour_blend (colour *c, double fraction, colour *other); 60 | 61 | void 62 | colour_darker (colour *dest, double fraction, colour *src); 63 | 64 | boolean 65 | colour_valid_state (const colour *c); 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /examples/ras_top_text.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | MolScript v2.1: Ras p21 in complex with Mg and GDP 4 | 5 | 6 | 7 | 8 | 9 |

Ras p21 in complex with Mg and GDP

10 | 11 |

12 | Three different VRML representations are available for the Ras p21 13 | structure. They all use the schematic representation of secondary 14 | structure, where alpha-helices are shown as helical ribbons, and 15 | beta-strands as arrows. 16 |

17 | 31 | 32 |

33 | Some features of the ras p21 structure are explained here: 34 |

35 | 40 | 41 | Gallery page 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /code/segment.h: -------------------------------------------------------------------------------- 1 | /* segment.h 2 | 3 | MolScript v2.1.2 4 | 5 | Segment data structure and routines. 6 | 7 | Copyright (C) 1997-1998 Per Kraulis 8 | 18-Aug-1997 split out of vrml.c; generalized 9 | */ 10 | 11 | #ifndef SEGMENT_H 12 | #define SEGMENT_H 1 13 | 14 | #include "clib/vector3.h" 15 | #include "clib/colour.h" 16 | 17 | typedef struct { 18 | vector3 p; 19 | colour c; 20 | boolean new; 21 | } line_segment; 22 | 23 | extern line_segment *line_segments; 24 | extern int line_segment_count; 25 | 26 | void line_segment_init (void); 27 | line_segment *line_segment_next (void); 28 | 29 | typedef struct { 30 | vector3 p1, p2, p3, p4; 31 | vector3 n1, n2, n3, n4; 32 | colour c; 33 | } strand_segment; 34 | 35 | extern strand_segment *strand_segments; 36 | extern int strand_segment_count; 37 | 38 | void strand_segment_init (void); 39 | strand_segment *strand_segment_next (void); 40 | 41 | typedef struct { 42 | vector3 p1, p2; 43 | vector3 a, n; 44 | colour c; 45 | } helix_segment; 46 | 47 | extern helix_segment *helix_segments; 48 | extern int helix_segment_count; 49 | 50 | void helix_segment_init (void); 51 | helix_segment *helix_segment_next (void); 52 | 53 | typedef struct { 54 | vector3 p, p1, p2, p3, p4; 55 | vector3 n1, n2, n3, n4; 56 | colour c; 57 | } coil_segment; 58 | 59 | extern coil_segment *coil_segments; 60 | extern int coil_segment_count; 61 | 62 | void coil_segment_init (void); 63 | coil_segment *coil_segment_next (void); 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /code/clib/aa_lookup.h: -------------------------------------------------------------------------------- 1 | #ifndef AA_LOOKUP_H 2 | #define AA_LOOKUP_H 1 3 | 4 | #include 5 | 6 | int 7 | aa_ordinal (char *c3); 8 | 9 | char 10 | aa_3to1 (char *c3); 11 | 12 | char * 13 | aa_1to3 (char c1); 14 | 15 | char 16 | aa_all3to1 (char *c3); 17 | 18 | int 19 | aa_int (char c1); 20 | 21 | char 22 | aa_code (int aa_int); 23 | 24 | boolean 25 | is_amino_acid_type (char *c3); 26 | 27 | boolean 28 | is_water_type (char *c3); 29 | 30 | boolean 31 | is_nucleic_acid_type (char *c3); 32 | 33 | double 34 | aa_abundance (int aa_int); 35 | 36 | double 37 | aa_fauchere_pliska (int aa_int); 38 | 39 | double 40 | aa_fauchere_pliska_normalized (int aa_int); 41 | 42 | double 43 | aa_kyte_doolittle (int aa_int); 44 | 45 | double 46 | aa_kyte_doolittle_normalized (int aa_int); 47 | 48 | boolean 49 | aa_conformation_special (int aa_int); 50 | 51 | boolean 52 | aa_ring (int aa_int); 53 | 54 | boolean 55 | aa_hbond_forming (int aa_int); 56 | 57 | boolean 58 | aa_hbond_donor (int aa_int); 59 | 60 | boolean 61 | aa_hbond_acceptor (int aa_int); 62 | 63 | boolean 64 | aa_polar (int aa_int); 65 | 66 | boolean 67 | aa_aromatic (int aa_int); 68 | 69 | boolean 70 | aa_positive_charge (int aa_int); 71 | 72 | boolean 73 | aa_negative_charge (int aa_int); 74 | 75 | boolean 76 | aa_charged (int aa_int); 77 | 78 | boolean 79 | aa_zn_binding (int aa_int); 80 | 81 | int 82 | aa_random (double rnd); 83 | 84 | int 85 | aa_random_abundance (double rnd); 86 | 87 | int 88 | aa_random_distribution (double rnd, double distribution[20]); 89 | 90 | #endif 91 | -------------------------------------------------------------------------------- /code/vrml.h: -------------------------------------------------------------------------------- 1 | /* vrml.h 2 | 3 | MolScript v2.1.2 4 | 5 | VRML V2.0. 6 | 7 | Copyright (C) 1997-1998 Per Kraulis 8 | 4-Dec-1996 first attempts 9 | 31-Mar-1997 fairly finished 10 | 18-Aug-1997 split out and generalized segment handling 11 | 15-Oct-1997 USE/DEF for helix and strand different surfaces 12 | */ 13 | 14 | #ifndef MOLSCRIPT_VRML_H 15 | #define MOLSCRIPT_VRML_H 1 16 | 17 | #include "col.h" 18 | #include "coord.h" 19 | 20 | void vrml_set (void); 21 | 22 | void vrml_first_plot (void); 23 | void vrml_finish_output (void); 24 | void vrml_start_plot (void); 25 | void vrml_finish_plot (void); 26 | 27 | void vrml_set_area (void); 28 | void vrml_set_background (void); 29 | void vrml_anchor_start (char *str); 30 | void vrml_anchor_description (char *str); 31 | void vrml_anchor_parameter (char *str); 32 | void vrml_anchor_start_geometry (void); 33 | void vrml_anchor_finish (void); 34 | void vrml_lod_start (void); 35 | void vrml_lod_finish (void); 36 | void vrml_lod_start_group (void); 37 | void vrml_lod_finish_group (void); 38 | void vrml_viewpoint_start (char *str); 39 | void vrml_viewpoint_output (void); 40 | void vrml_ms_directionallight (void); 41 | void vrml_ms_pointlight (void); 42 | void vrml_ms_spotlight (void); 43 | 44 | void vrml_coil (void); 45 | void vrml_cylinder (vector3 *v1, vector3 *v2); 46 | void vrml_helix (void); 47 | void vrml_label (vector3 *p, char *label, colour *c); 48 | void vrml_line (boolean polylines); 49 | void vrml_points (int colours); 50 | void vrml_sphere (at3d *at, double radius); 51 | void vrml_stick (vector3 *v1, vector3 *v2, double r1, double r2, colour *c); 52 | void vrml_strand (void); 53 | 54 | void vrml_object (int code, vector3 *triplets, int count); 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /examples/ras_molauto.in: -------------------------------------------------------------------------------- 1 | ! MolScript v2.1 input file 2 | ! generated by MolAuto v1.1 3 | 4 | title "C-H-RAS P21 PROTEIN (CATALYTIC DOMAIN, RESIDUES 1 - 166) COMPLEXED WITH GDP AND MG (NMR, RESTRAINED MINIMIZED AVERAGE)" 5 | 6 | plot 7 | 8 | read mol "ras.pdb"; 9 | 10 | transform atom * by centre position atom *; 11 | 12 | set segments 2; 13 | 14 | set planecolour hsb 0.6667 1 1; 15 | coil from 1 to 2; 16 | set planecolour hsb 0.6316 1 1; 17 | strand from 2 to 9; 18 | set planecolour hsb 0.5965 1 1; 19 | coil from 9 to 15; 20 | set planecolour hsb 0.5614 1 1; 21 | helix from 15 to 25; 22 | set planecolour hsb 0.5263 1 1; 23 | coil from 25 to 38; 24 | set planecolour hsb 0.4912 1 1; 25 | strand from 38 to 46; 26 | set planecolour hsb 0.4561 1 1; 27 | coil from 46 to 49; 28 | set planecolour hsb 0.4211 1 1; 29 | strand from 49 to 57; 30 | set planecolour hsb 0.386 1 1; 31 | coil from 57 to 66; 32 | set planecolour hsb 0.3509 1 1; 33 | helix from 66 to 75; 34 | set planecolour hsb 0.3158 1 1; 35 | coil from 75 to 77; 36 | set planecolour hsb 0.2807 1 1; 37 | strand from 77 to 84; 38 | set planecolour hsb 0.2456 1 1; 39 | coil from 84 to 87; 40 | set planecolour hsb 0.2105 1 1; 41 | helix from 87 to 104; 42 | set planecolour hsb 0.1754 1 1; 43 | coil from 104 to 110; 44 | set planecolour hsb 0.1404 1 1; 45 | strand from 110 to 117; 46 | set planecolour hsb 0.1053 1 1; 47 | coil from 117 to 127; 48 | set planecolour hsb 0.07018 1 1; 49 | helix from 127 to 138; 50 | set planecolour hsb 0.03509 1 1; 51 | coil from 138 to 152; 52 | set planecolour hsb 0 1 1; 53 | helix from 152 to 166; 54 | 55 | set colourparts on; 56 | bonds in residue 200; 57 | cpk in residue 201; 58 | 59 | end_plot 60 | -------------------------------------------------------------------------------- /examples/ras_rmsd.in: -------------------------------------------------------------------------------- 1 | ! MolScript v2.1 input file 2 | ! generated by MolAuto v1.1 3 | ! modified by hand 4 | 5 | ! Standard view, colours according to RMSD of CA atoms. 6 | 7 | title "c-H-ras p21 protein (1-166), complex with GDP and Mg" 8 | 9 | plot 10 | 11 | window 40; 12 | 13 | read mol "ras.pdb"; 14 | 15 | transform atom * 16 | by centre position atom * 17 | by rotation 18 | 0.450861 0.724522 -0.521337 19 | 0.328525 0.408374 0.851647 20 | 0.829937 -0.555246 -0.0539039 21 | by translation -2 1 0 22 | ; 23 | 24 | set segments 6; 25 | 26 | set colourparts on, 27 | residuecolour amino-acids b-factor 0.3 1.5 from blue to red; 28 | 29 | coil from 1 to 2; 30 | strand from 2 to 9; 31 | coil from 9 to 15; 32 | helix from 15 to 25; 33 | coil from 25 to 38; 34 | strand from 38 to 46; 35 | coil from 46 to 49; 36 | strand from 49 to 57; 37 | coil from 57 to 66; 38 | helix from 66 to 75; 39 | coil from 75 to 77; 40 | strand from 77 to 84; 41 | coil from 84 to 87; 42 | helix from 87 to 104; 43 | coil from 104 to 110; 44 | strand from 110 to 117; 45 | coil from 117 to 127; 46 | helix from 127 to 138; 47 | coil from 138 to 152; 48 | helix from 152 to 166; 49 | 50 | set atomcolour in residue 200 green; 51 | cpk in residue 200; 52 | cpk in residue 201; 53 | 54 | viewpoint "GDP molecule" from position require in type GDP and atom N* 55 | to position require in type GDP and atom P* 10; 56 | 57 | viewpoint "Mg ion" from position in require type HOH 58 | and either residue 3 or residue 2 59 | to position in type MG 10; 60 | 61 | viewpoint "far away" origin position in type GDP 100; 62 | 63 | end_plot 64 | -------------------------------------------------------------------------------- /code/clib/dynstring.h: -------------------------------------------------------------------------------- 1 | #ifndef DYNSTRING_H 2 | #define DYNSTRING_H 1 3 | 4 | #include 5 | 6 | typedef struct { 7 | char *string; 8 | int capacity; 9 | int length; 10 | } dynstring; 11 | 12 | boolean 13 | ds_valid_state (const dynstring *ds); 14 | 15 | dynstring * 16 | ds_create (const char *str); 17 | 18 | dynstring * 19 | ds_subcreate (const char *str, int first, int last); 20 | 21 | dynstring * 22 | ds_clone (dynstring *ds); 23 | 24 | dynstring * 25 | ds_subclone (dynstring *ds, int first, int last); 26 | 27 | dynstring * 28 | ds_allocate (const int capacity); 29 | 30 | void 31 | ds_reallocate (dynstring *ds, const int capacity); 32 | 33 | void 34 | ds_delete (dynstring *ds); 35 | 36 | void 37 | ds_set (dynstring *ds, const char *str); 38 | 39 | void 40 | ds_subset (dynstring *ds, const char *str, int first, int last); 41 | 42 | void 43 | ds_cat (dynstring *ds, const char *str); 44 | 45 | void 46 | ds_subcat (dynstring *ds, const char *str, int first, int last); 47 | 48 | void 49 | ds_add (dynstring *ds, const char c); 50 | 51 | void 52 | ds_cat_int (dynstring *ds, const int i); 53 | 54 | void 55 | ds_append (dynstring *ds1, const dynstring *ds2); 56 | 57 | void 58 | ds_replace (dynstring *ds, const int pos, const int len, const char *str); 59 | 60 | void 61 | ds_fill_blanks (dynstring *ds, const int length); 62 | 63 | void 64 | ds_remove_blanks (dynstring *ds); 65 | 66 | void 67 | ds_pad_blanks (dynstring *ds, int length); 68 | 69 | void 70 | ds_truncate (dynstring *ds, int length); 71 | 72 | void 73 | ds_left_adjust (dynstring *ds); 74 | 75 | void 76 | ds_right_adjust (dynstring *ds); 77 | 78 | void 79 | ds_reset (dynstring *ds); 80 | 81 | void 82 | ds_to_upper (dynstring *ds); 83 | 84 | void 85 | ds_to_lower (dynstring *ds); 86 | 87 | #endif 88 | -------------------------------------------------------------------------------- /code/clib/sgi_image.h: -------------------------------------------------------------------------------- 1 | /* sgi_image.h 2 | 3 | SGI (aka RGB) format image file i/o. 4 | 5 | clib v1.1 6 | 7 | This is based on the specification of the SGI image file format: 8 | http://reality.sgi.com/grafica/sgiimage.html 9 | 10 | Copyright (C) 1997-1998 Per Kraulis 11 | 26-Sep-1997 started 12 | 28-Sep-1997 write char routine implemented 13 | 14 | to do: 15 | - short routines not implemented 16 | - read routines not implemented 17 | - RLE needs optimizing: check if row actually gets compressed 18 | */ 19 | 20 | #ifndef SGI_IMAGE_H 21 | #define SGI_IMAGE_H 22 | 23 | #include 24 | 25 | typedef struct { 26 | unsigned short xsize, ysize, zsize; 27 | char storage, bpc; 28 | unsigned short dimension; 29 | long pinmin, pinmax; 30 | char name[80]; 31 | 32 | FILE *file; 33 | int current_rownum, current_channel; 34 | int tablen; 35 | long *start_table, *length_table; 36 | } sgi_image; 37 | 38 | sgi_image *sgiimg_create (void); 39 | void sgiimg_delete (sgi_image *img); 40 | 41 | void sgiimg_set_size (sgi_image *img, int width, int height); 42 | void sgiimg_set_verbatim (sgi_image *img); 43 | void sgiimg_set_rle (sgi_image *img); 44 | void sgiimg_set_char (sgi_image *img); 45 | void sgiimg_set_short (sgi_image *img); 46 | void sgiimg_set_bw (sgi_image *img); 47 | void sgiimg_set_rgb (sgi_image *img); 48 | void sgiimg_set_rgba (sgi_image *img); 49 | void sgiimg_set_minmax (sgi_image *img, long min, long max); 50 | void sgiimg_set_name (sgi_image *img, char *str); 51 | 52 | int sgiimg_file_create (sgi_image *img, char *filename); 53 | int sgiimg_file_init (sgi_image *img); 54 | int sgiimg_file_open (sgi_image *img, char *filename); 55 | void sgiimg_file_close (sgi_image *img); 56 | 57 | int sgiimg_write_next_char_row (sgi_image *img, unsigned char *row); 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /docs/interface.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | MolScript v2.1: Interface to external objects 4 | 5 | 6 | 7 | 8 | 9 |

Interface to external objects

10 | 11 | A new feature of MolScript v2 is the interface to external graphical 12 | objects. This interface allows graphical objects created by other 13 | programs to be included in images. For example, the graphical objects 14 | may be a molecular surface generated by some external program, or it 15 | may be a chicken-wire representation of an electron density map. 16 |

17 | The interface is based on a simple file format definition, which 18 | may contain the graphical primitives points, lines and triangular 19 | surfaces, in any combination. 20 | 21 |

22 | 23 | The external object file format is described in 24 | detail here 25 | 26 | . 27 |

28 | Several parameters in the MolScript 29 | graphics state affect the appearance of the 30 | external objects in the image. Some of the object primitives in the 31 | file may contain specifications of colour and surface normals. 32 |

33 | The external graphical object file is included in the image by the 34 | object command, which reads the 35 | file and outputs the specified objects to the image according the the 36 | state parameters at that point in the input file. An important 37 | parameter is the 38 | objecttransform parameter, 39 | which determines whether or not the coordinates in the object file are 40 | to be transformed by the most recently used transformation matrix. 41 |

42 |


43 | Top page 44 | 45 | 46 | -------------------------------------------------------------------------------- /examples/ras_cyl.in: -------------------------------------------------------------------------------- 1 | ! MolScript v2.1 input file 2 | ! generated by MolAuto v1.1 3 | ! modified by hand 4 | 5 | ! Standard view, cylinders for helices, secondary structure colours. 6 | 7 | title "c-H-ras p21 protein (1-166), complex with GDP and Mg" 8 | 9 | plot 10 | 11 | window 40; 12 | 13 | read mol "ras.pdb"; 14 | 15 | transform atom * 16 | by centre position atom * 17 | by rotation 18 | 0.450861 0.724522 -0.521337 19 | 0.328525 0.408374 0.851647 20 | 0.829937 -0.555246 -0.0539039 21 | by translation -2 1 0 22 | ; 23 | 24 | set planecolour purple; 25 | coil from 1 to 2; 26 | coil from 46 to 49; 27 | coil from 75 to 77; 28 | coil from 84 to 87; 29 | coil from 104 to 110; 30 | coil from 117 to 127; 31 | coil from 138 to 152; 32 | 33 | set planecolour orange; 34 | coil from 9 to 15; 35 | coil from 25 to 38; 36 | coil from 57 to 66; 37 | 38 | set planecolour green; 39 | strand from 2 to 9; 40 | strand from 38 to 46; 41 | strand from 49 to 57; 42 | strand from 77 to 84; 43 | strand from 110 to 117; 44 | 45 | set planecolour crimson; 46 | cylinder from 15 to 25; 47 | cylinder from 66 to 75; 48 | cylinder from 87 to 104; 49 | cylinder from 127 to 138; 50 | cylinder from 152 to 166; 51 | 52 | set colourparts on; 53 | ball-and-stick in residue 200; 54 | cpk in residue 201; 55 | 56 | viewpoint "GDP molecule" from position require in type GDP and atom N* 57 | to position require in type GDP and atom P* 10; 58 | 59 | viewpoint "Mg ion" from position in require type HOH 60 | and either residue 3 or residue 2 61 | to position in type MG 10; 62 | 63 | viewpoint "far away" origin position in type GDP 100; 64 | 65 | end_plot 66 | -------------------------------------------------------------------------------- /examples/ras_min_vrml.in: -------------------------------------------------------------------------------- 1 | ! MolScript v2.1 input file 2 | ! generated by MolAuto v1.0 3 | ! modified by hand 4 | 5 | ! VRML frames example, minimal quality. 6 | 7 | title "c-H-Ras p21 protein (1-166), comples with GDP, Mg" 8 | 9 | plot 10 | 11 | read mol "ras.pdb"; 12 | 13 | set segments 2, strandthickness 0, coilradius 0; 14 | 15 | set planecolour green; 16 | helix from 15 to 24; 17 | helix from 66 to 74; 18 | helix from 88 to 103; 19 | helix from 126 to 134; 20 | helix from 152 to 165; 21 | 22 | set planecolour red; 23 | strand from 2 to 10; 24 | strand from 38 to 45; 25 | strand from 50 to 57; 26 | strand from 77 to 81; 27 | strand from 111 to 115; 28 | strand from 140 to 143; 29 | 30 | set planecolour purple; 31 | anchor "ras_loops_text.html" 32 | description "effector loops" parameter "target=text" 33 | { 34 | coil from 24 to 38; 35 | coil from 57 to 66; 36 | }; 37 | 38 | set planecolour yellow; 39 | coil from 1 to 2; 40 | turn from 10 to 15; 41 | coil from 45 to 50; 42 | coil from 74 to 77; 43 | coil from 81 to 88; 44 | coil from 103 to 111; 45 | coil from 115 to 126; 46 | coil from 134 to 140; 47 | coil from 143 to 152; 48 | coil from 165 to 166; 49 | 50 | set colourparts on; 51 | bonds require not hydrogens and in type HOH; 52 | 53 | anchor "ras_gdp_text.html" 54 | description "GDP molecule" parameter "target=text" 55 | { 56 | bonds in type GDP; 57 | }; 58 | 59 | anchor "ras_mg_text.html" 60 | description "Mg ion" parameter "target=text" 61 | { 62 | bonds in type MG; 63 | }; 64 | 65 | viewpoint "GDP molecule" from position require in type GDP and atom N* 66 | to position require in type GDP and atom P* 10; 67 | 68 | viewpoint "Mg ion" from position in require type HOH 69 | and either residue 3 or residue 2 70 | to position in type MG 10; 71 | 72 | viewpoint "far away" origin position in type GDP 100; 73 | 74 | end_plot 75 | -------------------------------------------------------------------------------- /code/clib/ogl_utils.c: -------------------------------------------------------------------------------- 1 | /* 2 | Some OpenGL utility procedures. 3 | 4 | This package relies on GLUT version 3.5 (and presumably higher). 5 | 6 | clib v1.1 7 | 8 | Copyright (C) 1997-1998 Per Kraulis 9 | 6-Aug-1997 first attempts 10 | 12-Jun-1998 reorganized, mod's for hgen 11 | */ 12 | 13 | #include "ogl_utils.h" 14 | 15 | /* public ==================== 16 | #include 17 | ==================== public */ 18 | 19 | #include 20 | #include 21 | #include 22 | 23 | #include 24 | 25 | #include 26 | 27 | 28 | /*------------------------------------------------------------*/ 29 | boolean 30 | ogl_check_errors (char *msg) 31 | /* 32 | Check if any OpenGL errors have occurred, output error message 33 | and return TRUE if so, otherwise FALSE. 34 | */ 35 | { 36 | GLenum error = glGetError(); 37 | 38 | if (error == GL_NO_ERROR) return FALSE; 39 | 40 | if (msg) fprintf (stderr, "%s", msg); 41 | while (error != GL_NO_ERROR) { 42 | fprintf (stderr, "OpenGL error: %s\n", gluErrorString (error)); 43 | error = glGetError(); 44 | } 45 | return TRUE; 46 | } 47 | 48 | 49 | /*------------------------------------------------------------*/ 50 | boolean 51 | ogl_display_mode_not_available (void) 52 | /* 53 | Check if the requested GLUT window display mode is 54 | not available. 55 | */ 56 | { 57 | if (! glutGet (GLUT_DISPLAY_MODE_POSSIBLE)) { 58 | err_message ("required OpenGL display mode not available on this system"); 59 | return TRUE; 60 | } else { 61 | return FALSE; 62 | } 63 | } 64 | 65 | 66 | /*------------------------------------------------------------*/ 67 | void 68 | ogl_display_mode_not_available_fatal (void) 69 | /* 70 | Check if the requested GLUT window display mode is 71 | not available and exit with failure if so. 72 | */ 73 | { 74 | if (ogl_display_mode_not_available()) { 75 | fprintf (stderr, "exiting..."); 76 | exit (EXIT_FAILURE); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /code/global.h: -------------------------------------------------------------------------------- 1 | /* global.h 2 | 3 | MolScript v2.1.2 4 | 5 | Global stuff. 6 | 7 | Copyright (C) 1997-1998 Per Kraulis 8 | 1-Dec-1996 first attempts 9 | 12-Sep-1997 rearranged modes 10 | */ 11 | 12 | #ifndef GLOBAL_H 13 | #define GLOBAL_H 1 14 | 15 | #include 16 | 17 | #include "clib/boolean.h" 18 | #include "clib/vector3.h" 19 | #include "clib/colour.h" 20 | 21 | #define UNDEFINED_MODE 0 22 | #define POSTSCRIPT_MODE 1 23 | #define RASTER3D_MODE 2 24 | #define VRML_MODE 3 25 | #define OPENGL_MODE 4 26 | #define EPS_MODE 5 27 | #define JPEG_MODE 6 28 | #define SGI_MODE 7 29 | #define PNG_MODE 8 30 | #define GIF_MODE 9 31 | 32 | #define PRINT(str) fprintf(outfile,"%s",(str)) 33 | 34 | extern const char program_str[]; 35 | extern const char copyright_str[]; 36 | extern char user_str[]; 37 | 38 | extern int output_mode; 39 | 40 | extern char *input_filename; 41 | extern char *output_filename; 42 | extern char *tmp_filename; 43 | extern FILE *outfile; 44 | extern boolean message_mode; 45 | extern boolean exit_on_error; 46 | extern boolean pretty_format; 47 | extern int output_width; 48 | extern int output_height; 49 | 50 | #define MAX_DSTACK 10 51 | extern double dstack [MAX_DSTACK]; 52 | extern int dstack_size; 53 | extern int ival; 54 | 55 | extern vector3 xaxis; 56 | extern vector3 yaxis; 57 | extern vector3 zaxis; 58 | 59 | extern char *title; 60 | extern int first_plot; 61 | 62 | int yyerror (char *s); 63 | int yyparse (void); 64 | void yywarning (char *s); 65 | 66 | void global_init(void); 67 | 68 | void push_double (double f); 69 | void clear_dstack (void); 70 | void pop_dstack (int slots); 71 | 72 | void do_nothing (void); 73 | void do_nothing_str (char *str); 74 | 75 | void banner (void); 76 | void not_implemented (const char *str); 77 | 78 | void process_arguments (int *argcp, char *argv[]); 79 | void set_outfile (const char *mode); 80 | 81 | void set_title (const char *str); 82 | void start_plot (void); 83 | 84 | void debug (const char *str); 85 | 86 | #endif 87 | -------------------------------------------------------------------------------- /examples/ras_vrml.in: -------------------------------------------------------------------------------- 1 | ! MolScript v2.1 input file 2 | ! generated by MolAuto v1.0 3 | ! modified by hand 4 | 5 | ! VRML frames example, nice quality. 6 | 7 | title "c-H-Ras p21 protein (1-166), comples with GDP, Mg" 8 | 9 | plot 10 | 11 | read mol "ras.pdb"; 12 | 13 | set segments 4, planecolour green; 14 | helix from 15 to 24; 15 | helix from 66 to 74; 16 | helix from 88 to 103; 17 | helix from 126 to 134; 18 | helix from 152 to 165; 19 | 20 | set segments 2, planecolour red; 21 | strand from 2 to 10; 22 | strand from 38 to 45; 23 | strand from 50 to 57; 24 | strand from 77 to 81; 25 | strand from 111 to 115; 26 | strand from 140 to 143; 27 | 28 | set planecolour purple; 29 | anchor "ras_loops_text.html" 30 | description "effector loops" parameter "target=text" 31 | { 32 | coil from 24 to 38; 33 | coil from 57 to 66; 34 | }; 35 | 36 | set planecolour yellow; 37 | coil from 1 to 2; 38 | turn from 10 to 15; 39 | coil from 45 to 50; 40 | coil from 74 to 77; 41 | coil from 81 to 88; 42 | coil from 103 to 111; 43 | coil from 115 to 126; 44 | coil from 134 to 140; 45 | coil from 143 to 152; 46 | coil from 165 to 166; 47 | 48 | set colourparts on, specularcolour white, shininess 0.2; 49 | 50 | anchor "ras_gdp_text.html" 51 | description "GDP molecule" parameter "target=text" 52 | { 53 | ball-and-stick in type GDP; 54 | }; 55 | 56 | ball-and-stick require not hydrogens and in type HOH; 57 | 58 | set segments 6, shininess 0.6; 59 | anchor "ras_mg_text.html" 60 | description "Mg ion" parameter "target=text" 61 | { 62 | cpk in type MG; 63 | }; 64 | 65 | viewpoint "GDP molecule" from position require in type GDP and atom N* 66 | to position require in type GDP and atom P* 10; 67 | 68 | viewpoint "Mg ion" from position in require type HOH 69 | and either residue 3 or residue 2 70 | to position in type MG 10; 71 | 72 | viewpoint "far away" origin position in type GDP 100; 73 | 74 | end_plot 75 | -------------------------------------------------------------------------------- /code/select.h: -------------------------------------------------------------------------------- 1 | /* select.h 2 | 3 | MolScript v2.1.2 4 | 5 | Atom and residue selection definitions. 6 | 7 | Copyright (C) 1997-1998 Per Kraulis 8 | 7-Dec-1996 first attempts 9 | 2-Jan-1997 largely finished 10 | */ 11 | 12 | #include "coord.h" 13 | 14 | typedef struct selection selection; 15 | 16 | struct selection { 17 | int *flags; 18 | selection *next, *prev; 19 | }; 20 | 21 | void push_atom_selection (void); 22 | void push_residue_selection (void); 23 | void pop_atom_selection (void); 24 | void pop_residue_selection (void); 25 | 26 | int count_atom_selections (void); 27 | int count_residue_selections (void); 28 | 29 | int select_atom_count (void); 30 | int select_residue_count (void); 31 | 32 | at3d **select_atom_list (int *atom_count); 33 | 34 | void select_atom_not (void); 35 | void select_atom_and (void); 36 | void select_atom_or (void); 37 | 38 | void select_residue_not (void); 39 | void select_residue_and (void); 40 | void select_residue_or (void); 41 | 42 | void select_atom_id (const char *item); 43 | void select_atom_res_id (const char *item); 44 | void select_atom_occupancy (void); 45 | void select_atom_b_factor (void); 46 | void select_atom_in (void); 47 | void select_atom_sphere (void); 48 | void select_atom_close (void); 49 | void select_atom_backbone (void); 50 | void select_atom_peptide (void); 51 | void select_atom_hydrogens (void); 52 | void select_atom_element (const char *item); 53 | 54 | void select_residue_molecule (const char *item); 55 | void select_residue_model (void); 56 | void select_residue_from_to (const char *item1, const char *item2); 57 | void select_residue_id (const char *item); 58 | void select_residue_type (const char *item); 59 | void select_residue_chain (const char *item); 60 | void select_residue_contains (void); 61 | void select_residue_amino_acids (void); 62 | void select_residue_waters (void); 63 | void select_residue_nucleotides (void); 64 | void select_residue_ligands (void); 65 | void select_residue_segid (const char *item); 66 | 67 | extern selection *current_atom_sel; 68 | extern selection *current_residue_sel; 69 | -------------------------------------------------------------------------------- /docs/distribution.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | MolScript v2.1: Distribution 4 | 5 | 6 | 7 | 8 | 9 |

Distribution

10 | 11 | The MolScript program is distributed as source code (ANSI C) together 12 | with Makefiles, documentation and example input files. You will have 13 | to compile the program yourself. 14 |

15 | The MolScript software can be obtained from its 16 | GitHub repository. 17 |

18 | Although GNU's bison 19 | (GNU's equivalent of yacc) was used to develop the 20 | program, it is not required to compile the program, since the C source 21 | code files produced by bison from the 22 | molscript.y file are included in the distribution. 23 |

24 | MolScript will compile with just the code that is included in the 25 | distribution. This gives the basic implementation which can output 26 | PostScript, 27 | Raster3D and 28 | VRML 2.0 files. 29 |

30 | If your computer systems supports 31 | OpenGL rendering, then an 32 | implementation allowing an interactive graphics window can be 33 | compiled. This also requires the 34 | GLUT library by Mark Kilgard. The 35 | OpenGL implementation allows several different image file output 36 | formats to be produced. Encapsulated PostScript Files (EPS) and SGI 37 | (aka RGB) image files are supported without any additional 38 | software. The JPEG, 39 | PNG and 40 | GIF image file formats require the 41 | corresponding libraries. None of these additional libraries are 42 | included in the MolScript distribution. You must 43 | fetch them and install them yourself. 44 |

45 | 46 |


47 | Top page 48 | 49 | 50 | -------------------------------------------------------------------------------- /examples/ras_shiny.in: -------------------------------------------------------------------------------- 1 | ! MolScript v2.1 input file 2 | ! generated by MolAuto v1.1 3 | ! modified by hand 4 | 5 | ! Standard view, rainbow colour scheme for coils, strands and helices. 6 | ! Specular colour white for coils, strand and helices. 7 | ! Increased shininess for atoms. 8 | 9 | title "c-H-ras p21 protein (1-166), complex with GDP and Mg" 10 | 11 | plot 12 | 13 | window 40; 14 | 15 | read mol "ras.pdb"; 16 | 17 | transform atom * 18 | by centre position atom * 19 | by rotation 20 | 0.450861 0.724522 -0.521337 21 | 0.328525 0.408374 0.851647 22 | 0.829937 -0.555246 -0.0539039 23 | by translation -2 1 0 24 | ; 25 | 26 | set specularcolour white; 27 | 28 | set planecolour hsb 0.6667 1 1; 29 | coil from 1 to 2; 30 | set planecolour hsb 0.6316 1 1; 31 | strand from 2 to 9; 32 | set planecolour hsb 0.5965 1 1; 33 | coil from 9 to 15; 34 | set planecolour hsb 0.5614 1 1; 35 | helix from 15 to 25; 36 | set planecolour hsb 0.5263 1 1; 37 | coil from 25 to 38; 38 | set planecolour hsb 0.4912 1 1; 39 | strand from 38 to 46; 40 | set planecolour hsb 0.4561 1 1; 41 | coil from 46 to 49; 42 | set planecolour hsb 0.4211 1 1; 43 | strand from 49 to 57; 44 | set planecolour hsb 0.386 1 1; 45 | coil from 57 to 66; 46 | set planecolour hsb 0.3509 1 1; 47 | helix from 66 to 75; 48 | set planecolour hsb 0.3158 1 1; 49 | coil from 75 to 77; 50 | set planecolour hsb 0.2807 1 1; 51 | strand from 77 to 84; 52 | set planecolour hsb 0.2456 1 1; 53 | coil from 84 to 87; 54 | set planecolour hsb 0.2105 1 1; 55 | helix from 87 to 104; 56 | set planecolour hsb 0.1754 1 1; 57 | coil from 104 to 110; 58 | set planecolour hsb 0.1404 1 1; 59 | strand from 110 to 117; 60 | set planecolour hsb 0.1053 1 1; 61 | coil from 117 to 127; 62 | set planecolour hsb 0.07018 1 1; 63 | helix from 127 to 138; 64 | set planecolour hsb 0.03509 1 1; 65 | coil from 138 to 152; 66 | set planecolour hsb 0 1 1; 67 | helix from 152 to 166; 68 | 69 | set colourparts on, shininess 0.6; 70 | ball-and-stick in residue 200; 71 | cpk in residue 201; 72 | 73 | end_plot 74 | -------------------------------------------------------------------------------- /code/clib/ogl_bitmap_character.c: -------------------------------------------------------------------------------- 1 | /* 2 | OpenGL bitmap character and string output. 3 | 4 | This is an optimized version of the GLUT library procedure 5 | glutBitmapCharacter. It assumes that the correct graphics state 6 | (as regards the pixelstore modes) has been set. The required values 7 | for the pixelstore modes are the default values (defined in the OpenGL 8 | specification), *except* for glPixelStorei (GL_UNPACK_ALIGNMENT, 1). 9 | 10 | This package relies on GLUT version 3.6. 11 | 12 | clib v1.1 13 | 14 | Copyright (C) 1998 Per Kraulis 15 | 6-Feb-1998 first attempts 16 | */ 17 | 18 | #include "ogl_bitmap_character.h" 19 | 20 | /* public ==================== 21 | #include 22 | ==================== public */ 23 | 24 | #include 25 | 26 | #include <../lib/glut/glutbitmap.h> 27 | 28 | 29 | /*------------------------------------------------------------*/ 30 | void 31 | ogl_bitmap_character (void *font, int c) 32 | /* 33 | Output the character using the given GLUT bitmap font. 34 | The font must be a GLUTbitmapFont. 35 | The raster position must be defined. 36 | */ 37 | { 38 | const BitmapCharRec *ch; 39 | BitmapFontPtr fontinfo; 40 | 41 | /* pre */ 42 | assert (font); 43 | 44 | #if defined(WIN32) 45 | fontinfo = (BitmapFontPtr) __glutFont(font); 46 | #else 47 | fontinfo = (BitmapFontPtr) font; 48 | #endif 49 | 50 | if (c < fontinfo->first || 51 | c >= fontinfo->first + fontinfo->num_chars) 52 | return; 53 | ch = fontinfo->ch[c - fontinfo->first]; 54 | if (ch) { 55 | glBitmap(ch->width, ch->height, ch->xorig, ch->yorig, 56 | ch->advance, 0, ch->bitmap); 57 | } 58 | } 59 | 60 | 61 | /*------------------------------------------------------------*/ 62 | void 63 | ogl_bitmap_string (void *font, char *str) 64 | /* 65 | Output the string using the given GLUT bitmap font. 66 | The font must be a GLUTbitmapFont. 67 | The raster position must be defined. 68 | */ 69 | { 70 | /* pre */ 71 | assert (font); 72 | assert (str); 73 | 74 | for ( ; *str; str++) ogl_bitmap_character (font, *str); 75 | } 76 | -------------------------------------------------------------------------------- /code/clib/vector3.h: -------------------------------------------------------------------------------- 1 | #ifndef VECTOR3_H 2 | #define VECTOR3_H 1 3 | 4 | #include 5 | 6 | typedef struct { 7 | double x, y, z; 8 | } vector3; 9 | 10 | void 11 | v3_initialize (vector3 *dest, const double x, const double y, const double z); 12 | 13 | void 14 | v3_sum (vector3 *dest, const vector3 *v1, const vector3 *v2); 15 | 16 | void 17 | v3_difference (vector3 *dest, const vector3 *v1, const vector3 *v2); 18 | 19 | void 20 | v3_scaled (vector3 *dest, const double s, const vector3 *src); 21 | 22 | void 23 | v3_add (vector3 *dest, const vector3 *v); 24 | 25 | void 26 | v3_subtract (vector3 *dest, const vector3 *v); 27 | 28 | void 29 | v3_scale (vector3 *dest, const double s); 30 | 31 | void 32 | v3_invert (vector3 *v); 33 | 34 | void 35 | v3_reverse (vector3 *v); 36 | 37 | void 38 | v3_sum_scaled (vector3 *dest, const vector3 *v1, 39 | const double s, const vector3 *v2); 40 | 41 | void 42 | v3_add_scaled (vector3 *dest, const double s, const vector3 *v); 43 | 44 | double 45 | v3_length (const vector3 *v); 46 | 47 | double 48 | v3_angle (const vector3 *v1, const vector3 *v2); 49 | 50 | double 51 | v3_angle_points (const vector3 *p1, const vector3 *p2, const vector3 *p3); 52 | 53 | double 54 | v3_torsion (const vector3 *p1, const vector3 *v1, 55 | const vector3 *p2, const vector3 *v2); 56 | 57 | double 58 | v3_torsion_points (const vector3 *p1, const vector3 *p2, 59 | const vector3 *p3, const vector3 *p4); 60 | 61 | double 62 | v3_dot_product (const vector3 *v1, const vector3 *v2); 63 | 64 | void 65 | v3_cross_product (vector3 *vz, const vector3 *vx, const vector3 *vy); 66 | 67 | void 68 | v3_triangle_normal (vector3 *n, 69 | const vector3 *p1, const vector3 *p2, const vector3 *p3); 70 | 71 | double 72 | v3_sqdistance (const vector3 *p1, const vector3 *p2); 73 | 74 | double 75 | v3_distance (const vector3 *p1, const vector3 *p2); 76 | 77 | boolean 78 | v3_close (const vector3 *v1, const vector3 *v2, const double sqdistance); 79 | 80 | void 81 | v3_normalize (vector3 *v); 82 | 83 | void 84 | v3_middle (vector3 *dest, const vector3 *p1, const vector3 *p2); 85 | 86 | void 87 | v3_between (vector3 *dest, 88 | const vector3 *p1, const vector3 *p2, const double fraction); 89 | 90 | int 91 | v3_different (const vector3 *v1, const vector3 *v2); 92 | 93 | #endif 94 | -------------------------------------------------------------------------------- /code/clib/vrml.h: -------------------------------------------------------------------------------- 1 | #ifndef VRML_H 2 | #define VRML_H 1 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | void 11 | vrml_initialize (void); 12 | 13 | int 14 | vrml_header (void); 15 | 16 | void 17 | vrml_comment (char *comment); 18 | 19 | void 20 | vrml_worldinfo (char *title, char *info); 21 | 22 | void 23 | vrml_navigationinfo (double speed, char *type); 24 | 25 | void 26 | vrml_viewpoint (vector3 *pos, vector3 *ori, double rot, 27 | double fov, char *descr); 28 | 29 | void 30 | vrml_fog (int type_exp, double r, colour *c); 31 | 32 | void 33 | vrml_s_newline (char *str); 34 | 35 | void 36 | vrml_s_quoted (char *str); 37 | 38 | void 39 | vrml_i (int i); 40 | 41 | void 42 | vrml_f (double d); 43 | 44 | void 45 | vrml_g (double d); 46 | 47 | void 48 | vrml_f2 (double d); 49 | 50 | void 51 | vrml_g3 (double d); 52 | 53 | void 54 | vrml_v3 (vector3 *v); 55 | 56 | void 57 | vrml_v3_g (vector3 *v); 58 | 59 | void 60 | vrml_v3_g3 (vector3 *v); 61 | 62 | void 63 | vrml_colour (colour *c); 64 | 65 | void 66 | vrml_rgb_colour (colour *c); 67 | 68 | void 69 | vrml_tri_indices (int base, int i1, int i2, int i3); 70 | 71 | void 72 | vrml_quad_indices (int base, int i1, int i2, int i3, int i4); 73 | 74 | void 75 | vrml_begin_node (void); 76 | 77 | void 78 | vrml_finish_node (void); 79 | 80 | void 81 | vrml_begin_list (void); 82 | 83 | void 84 | vrml_finish_list (void); 85 | 86 | boolean 87 | vrml_valid_name (char *name); 88 | 89 | void 90 | vrml_def (char *def); 91 | 92 | void 93 | vrml_proto (char *proto); 94 | 95 | void 96 | vrml_node (char *node); 97 | 98 | void 99 | vrml_list (char *list); 100 | 101 | void 102 | vrml_bbox (vector3 *center, vector3 *size); 103 | 104 | void 105 | vrml_material (colour *dc, colour *ec, colour *sc, 106 | double ai, double sh, double tr); 107 | 108 | void 109 | vrml_directionallight (double in, double ai, colour *c, vector3 *dir); 110 | 111 | void 112 | vrml_pointlight (double in, double ai, colour *c, 113 | vector3 *loc, double r, vector3 *att); 114 | 115 | void 116 | vrml_spotlight (double in, double ai, colour *c, 117 | vector3 *loc, vector3 *dir, double bw, double coa, 118 | double r, vector3 *att); 119 | 120 | #endif 121 | -------------------------------------------------------------------------------- /code/clib/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile 2 | # 3 | # clib for MolScript v2.1 4 | # 5 | # NOTE: 6 | # This Makefile cannot be used on its own. It must be used 7 | # indirectly from the Makefile in the molscript directory. 8 | # 9 | # Per Kraulis 10 | # 12-Aug-1998 reorganized for v2.1 11 | 12 | #------------------------------------------------------------ 13 | # Command execution shell. 14 | SHELL = /bin/sh 15 | 16 | # Original clib directory. 17 | ORIGCLIBDIR = $(HOME)/clib 18 | 19 | # Command 'cp' flags. 20 | # -p = copy also time-stamps 21 | CPFLAGS = -p 22 | 23 | #------------------------------------------------------------ 24 | CSRC = args.c str_utils.c dynstring.c err.c indent.c \ 25 | vector3.c matrix3.c quaternion.c body3d.c extent3d.c \ 26 | io_utils.c colour.c key_value.c named_data.c double_hash.c \ 27 | hermite_curve.c element_lookup.c aa_lookup.c mol3d.c mol3d_init.c \ 28 | mol3d_io.c mol3d_utils.c mol3d_chain.c mol3d_secstruc.c \ 29 | sgi_image.c vrml.c ogl_utils.c ogl_body.c ogl_bitmap_character.c 30 | 31 | HSRC = args.h str_utils.h dynstring.h err.h indent.h boolean.h \ 32 | vector3.h matrix3.h quaternion.h body3d.h extent3d.h angle.h \ 33 | io_utils.h colour.h key_value.h named_data.h double_hash.h \ 34 | hermite_curve.h element_lookup.h aa_lookup.h mol3d.h mol3d_init.h \ 35 | mol3d_io.h mol3d_utils.h mol3d_chain.h mol3d_secstruc.h \ 36 | sgi_image.h vrml.h ogl_utils.h ogl_body.h ogl_bitmap_character.h 37 | 38 | #------------------------------------------------------------ 39 | src: 40 | for file in $(CSRC) $(HSRC); do \ 41 | cp $(CPFLAGS) $(ORIGCLIBDIR)/$$file . ; \ 42 | done 43 | rm -f clib.a 44 | 45 | 46 | #------------------------------------------------------------ 47 | OBJ = args.o str_utils.o dynstring.o err.o indent.o \ 48 | vector3.o matrix3.o quaternion.o body3d.o extent3d.o \ 49 | io_utils.o colour.o key_value.o named_data.o double_hash.o \ 50 | hermite_curve.o element_lookup.o aa_lookup.o mol3d.o mol3d_init.o \ 51 | mol3d_io.o mol3d_utils.o mol3d_chain.o mol3d_secstruc.o \ 52 | sgi_image.o vrml.o $(OPENGLCLIBOBJ) 53 | 54 | #------------------------------------------------------------ 55 | clib.a: $(OBJ) 56 | ar -cru clib.a $(OBJ) 57 | 58 | clean: 59 | rm -f clib.a *.o 60 | 61 | veryclean: 62 | rm -f *.h *.c; make clean 63 | -------------------------------------------------------------------------------- /code/clib/args.c: -------------------------------------------------------------------------------- 1 | /* 2 | Command line argument handling. 3 | 4 | clib v1.1 5 | 6 | Copyright (C) 1997-1998 Per Kraulis 7 | 18-Feb-1997 first attempts 8 | 18-Jun-1998 mod's for hgen 9 | */ 10 | 11 | #include "args.h" 12 | 13 | /* public ==================== 14 | extern int args_number; 15 | extern char *args_command; 16 | ==================== public */ 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | #include 23 | #include 24 | 25 | 26 | /*============================================================*/ 27 | int args_number = 0; 28 | char *args_command; 29 | 30 | static char **args_array; 31 | static boolean *args_flagged = NULL; 32 | 33 | 34 | /*------------------------------------------------------------*/ 35 | void 36 | args_initialize (int argc, char *argv[]) 37 | { 38 | /* pre */ 39 | assert (argc >= 1); 40 | 41 | args_command = str_clone (argv[0]); 42 | args_number= argc; 43 | args_array = argv; 44 | if (args_flagged) free (args_flagged); 45 | args_flagged = calloc (argc, sizeof (boolean)); 46 | } 47 | 48 | 49 | /*------------------------------------------------------------*/ 50 | void 51 | args_flag (int number) 52 | { 53 | /* pre */ 54 | assert (number >= 0); 55 | assert (number < args_number); 56 | 57 | args_flagged[number] = TRUE; 58 | } 59 | 60 | /*------------------------------------------------------------*/ 61 | int 62 | args_unflagged (void) 63 | { 64 | int slot; 65 | 66 | for (slot = 0; slot < args_number; slot++) { 67 | if (!args_flagged[slot]) return slot; 68 | } 69 | 70 | return -1; 71 | } 72 | 73 | 74 | /*------------------------------------------------------------*/ 75 | int 76 | args_exists (char *arg) 77 | { 78 | int slot; 79 | 80 | /* pre */ 81 | assert (arg); 82 | assert (*arg); 83 | 84 | for (slot = 1; slot < args_number; slot++) { 85 | if (str_eq (arg, args_array[slot])) return slot; 86 | } 87 | 88 | return 0; 89 | } 90 | 91 | 92 | /*------------------------------------------------------------*/ 93 | char * 94 | args_item (int number) 95 | { 96 | /* pre */ 97 | assert (number >= 0); 98 | 99 | if (number >= args_number) { 100 | return NULL; 101 | } else { 102 | return args_array[number]; 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /examples/ras_std.in: -------------------------------------------------------------------------------- 1 | ! MolScript v2.1 input file 2 | ! generated by MolAuto v1.1 3 | ! modified by hand 4 | 5 | ! Standard view, rainbow colour scheme for coils, strands and helices. 6 | 7 | title "c-H-ras p21 protein (1-166), complex with GDP and Mg" 8 | 9 | plot 10 | 11 | window 40; 12 | 13 | read mol "ras.pdb"; 14 | 15 | transform atom * 16 | by centre position atom * 17 | by rotation 18 | 0.450861 0.724522 -0.521337 19 | 0.328525 0.408374 0.851647 20 | 0.829937 -0.555246 -0.0539039 21 | by translation -2 1 0 22 | ; 23 | 24 | set planecolour hsb 0.6667 1 1; 25 | coil from 1 to 2; 26 | set planecolour hsb 0.6316 1 1; 27 | strand from 2 to 9; 28 | set planecolour hsb 0.5965 1 1; 29 | coil from 9 to 15; 30 | set planecolour hsb 0.5614 1 1; 31 | helix from 15 to 25; 32 | set planecolour hsb 0.5263 1 1; 33 | coil from 25 to 38; 34 | set planecolour hsb 0.4912 1 1; 35 | strand from 38 to 46; 36 | set planecolour hsb 0.4561 1 1; 37 | coil from 46 to 49; 38 | set planecolour hsb 0.4211 1 1; 39 | strand from 49 to 57; 40 | set planecolour hsb 0.386 1 1; 41 | coil from 57 to 66; 42 | set planecolour hsb 0.3509 1 1; 43 | helix from 66 to 75; 44 | set planecolour hsb 0.3158 1 1; 45 | coil from 75 to 77; 46 | set planecolour hsb 0.2807 1 1; 47 | strand from 77 to 84; 48 | set planecolour hsb 0.2456 1 1; 49 | coil from 84 to 87; 50 | set planecolour hsb 0.2105 1 1; 51 | helix from 87 to 104; 52 | set planecolour hsb 0.1754 1 1; 53 | coil from 104 to 110; 54 | set planecolour hsb 0.1404 1 1; 55 | strand from 110 to 117; 56 | set planecolour hsb 0.1053 1 1; 57 | coil from 117 to 127; 58 | set planecolour hsb 0.07018 1 1; 59 | helix from 127 to 138; 60 | set planecolour hsb 0.03509 1 1; 61 | coil from 138 to 152; 62 | set planecolour hsb 0 1 1; 63 | helix from 152 to 166; 64 | 65 | set colourparts on; 66 | ball-and-stick in residue 200; 67 | cpk in residue 201; 68 | 69 | viewpoint "GDP molecule" from position require in type GDP and atom N* 70 | to position require in type GDP and atom P* 10; 71 | 72 | viewpoint "Mg ion" from position in require type HOH 73 | and either residue 3 or residue 2 74 | to position in type MG 10; 75 | 76 | viewpoint "far away" origin position in type GDP 100; 77 | 78 | end_plot 79 | -------------------------------------------------------------------------------- /code/sgi_img.c: -------------------------------------------------------------------------------- 1 | /* sgi_img.c 2 | 3 | MolScript v2.1.2 4 | 5 | SGI image file. 6 | 7 | This implementation relies on the 'image.c' code, and therefore 8 | implicitly on OpenGL and GLX. 9 | 10 | Copyright (C) 1997-1998 Per Kraulis 11 | 9-Sep-1997 started 12 | 11-Sep-1997 working 13 | 26-Sep-1997 use my own SGI image file interface 14 | */ 15 | 16 | #include 17 | 18 | #include 19 | 20 | #include "clib/sgi_image.h" 21 | 22 | #include "sgi_img.h" 23 | #include "global.h" 24 | #include "graphics.h" 25 | #include "image.h" 26 | #include "opengl.h" 27 | 28 | 29 | /*============================================================*/ 30 | static sgi_image *image; 31 | 32 | 33 | /*------------------------------------------------------------*/ 34 | void 35 | sgii_set (void) 36 | { 37 | ogl_set(); 38 | 39 | output_first_plot = sgii_first_plot; 40 | output_finish_output = sgii_finish_output; 41 | output_start_plot = ogl_start_plot_general; 42 | 43 | output_pickable = NULL; 44 | 45 | output_mode = SGI_MODE; 46 | } 47 | 48 | 49 | /*------------------------------------------------------------*/ 50 | void 51 | sgii_first_plot (void) 52 | { 53 | image_first_plot(); 54 | set_outfile ("wb"); 55 | 56 | image = sgiimg_create(); 57 | sgiimg_set_size (image, output_width, output_height); 58 | sgiimg_set_rle (image); 59 | if (title) sgiimg_set_name (image, title); 60 | 61 | image->file = outfile; 62 | if (! sgiimg_file_init (image)) 63 | yyerror ("could not create the SGI image output file"); 64 | } 65 | 66 | 67 | /*------------------------------------------------------------*/ 68 | void 69 | sgii_finish_output (void) 70 | { 71 | int rownum; 72 | unsigned char *row; 73 | 74 | image_render(); 75 | 76 | row = malloc (output_width * sizeof (unsigned char)); 77 | 78 | for (rownum = 0; rownum < output_height; rownum++) { 79 | glReadPixels (0, rownum, output_width, 1, GL_RED, GL_UNSIGNED_BYTE, row); 80 | sgiimg_write_next_char_row (image, row); 81 | } 82 | 83 | for (rownum = 0; rownum < output_height; rownum++) { 84 | glReadPixels (0, rownum, output_width, 1, GL_GREEN, GL_UNSIGNED_BYTE, row); 85 | sgiimg_write_next_char_row (image, row); 86 | } 87 | 88 | for (rownum = 0; rownum < output_height; rownum++) { 89 | glReadPixels (0, rownum, output_width, 1, GL_BLUE, GL_UNSIGNED_BYTE, row); 90 | sgiimg_write_next_char_row (image, row); 91 | } 92 | 93 | free (row); 94 | 95 | sgiimg_file_close (image); 96 | 97 | image_close(); 98 | } 99 | -------------------------------------------------------------------------------- /code/clib/io_utils.c: -------------------------------------------------------------------------------- 1 | /* io_utils 2 | 3 | File input/output utility procedures. 4 | 5 | clib v1.1 6 | 7 | Copyright (C) 1998 Per Kraulis 8 | 2-Mar-1998 first attempts 9 | 4-May-1998 modified for hgen, name changes 10 | 27-May-1998 added dynstring input 11 | */ 12 | 13 | #include "io_utils.h" 14 | 15 | /* public ==================== 16 | #include 17 | 18 | #include 19 | #include 20 | ==================== public */ 21 | 22 | #include 23 | 24 | 25 | /*------------------------------------------------------------*/ 26 | boolean 27 | io_fprint_str (FILE *file, const char *str) 28 | /* 29 | Write the string to the opened file. Return TRUE if successful. 30 | */ 31 | { 32 | /* pre */ 33 | assert (file); 34 | assert (str); 35 | 36 | return (fprintf (file, "%s", str) > 0); 37 | } 38 | 39 | 40 | /*------------------------------------------------------------*/ 41 | boolean 42 | io_fprint_str_length (FILE *file, const char *str, int length) 43 | /* 44 | Write the string to the opened file. The number of output characters 45 | is given by the length; blanks are used to pad if the string is not 46 | sufficiently long. Return TRUE if successful. 47 | */ 48 | { 49 | /* pre */ 50 | assert (file); 51 | assert (length >= 0); 52 | 53 | if (str) { 54 | while ((length-- > 0) && *str) { 55 | if (fputc (*str++, file) == EOF) return FALSE; 56 | } 57 | } 58 | 59 | while (length-- > 0) { 60 | if (fputc (' ', file) == EOF) return FALSE; 61 | } 62 | 63 | return TRUE; 64 | } 65 | 66 | 67 | /*------------------------------------------------------------*/ 68 | boolean 69 | io_fprint_blanks (FILE *file, int count) 70 | /* 71 | Write the given number of blank characters to the file. 72 | Return TRUE if successful. 73 | */ 74 | { 75 | /* pre */ 76 | assert (file); 77 | 78 | while (count > 0) { 79 | if (fputc (' ', file) == EOF) return FALSE; 80 | count--; 81 | } 82 | 83 | return TRUE; 84 | } 85 | 86 | 87 | /*------------------------------------------------------------*/ 88 | boolean 89 | io_fget_ds (FILE *file, dynstring *ds) 90 | /* 91 | Read one complete line (up to, but excluding, the '\n' character). 92 | Return TRUE if successful. 93 | */ 94 | { 95 | int ch; 96 | 97 | /* pre */ 98 | assert (file); 99 | assert (ds); 100 | assert (ds_valid_state (ds)); 101 | 102 | ds_reset (ds); 103 | while (ch = fgetc (file)) { 104 | if (ch == '\n') break; 105 | if (ch == EOF) break; 106 | ds_add (ds, ch); 107 | } 108 | 109 | return TRUE; 110 | } 111 | -------------------------------------------------------------------------------- /code/clib/hermite_curve.c: -------------------------------------------------------------------------------- 1 | /* 2 | Hermite parametric cubic 3D curve routines. 3 | 4 | clib v1.1 5 | 6 | Copyright (C) 1997-1998 Per Kraulis 7 | 2-Feb-1997 fairly finished 8 | 28-Oct-1997 added tangent routine 9 | 17-Jun-1998 mod's for hgen 10 | */ 11 | 12 | #include "hermite_curve.h" 13 | 14 | /* public ==================== 15 | #include 16 | ==================== public */ 17 | 18 | #include 19 | 20 | 21 | /*============================================================*/ 22 | static vector3 p1; 23 | static vector3 p2; 24 | static vector3 v1; 25 | static vector3 v2; 26 | 27 | 28 | /*------------------------------------------------------------*/ 29 | void 30 | hermite_set (vector3 *pos_start, vector3 *pos_finish, 31 | vector3 *vec_start, vector3 *vec_finish) 32 | /* 33 | Set the start and finish points and vectors of the Hermite curve. 34 | d */ 35 | { 36 | /* pre */ 37 | assert (pos_start); 38 | assert (pos_finish); 39 | assert (vec_start); 40 | assert (vec_finish); 41 | 42 | p1 = *pos_start; 43 | p2 = *pos_finish; 44 | v1 = *vec_start; 45 | v2 = *vec_finish; 46 | } 47 | 48 | 49 | /*------------------------------------------------------------*/ 50 | void 51 | hermite_get (vector3 *p, double t) 52 | /* 53 | Return the point on the Hermite curve corresponding to the 54 | given parameter value t. 55 | */ 56 | { 57 | register double t2, t3, tp1, tp2, tv1, tv2; 58 | 59 | /* pre */ 60 | assert (p); 61 | assert (t >= 0.0); 62 | assert (t <= 1.0); 63 | 64 | t2 = t * t; 65 | t3 = t2 * t; 66 | tp1 = 2.0 * t3 - 3.0 * t2 + 1.0; 67 | tp2 = -2.0 * t3 + 3.0 * t2; 68 | tv1 = t3 - 2.0 * t2 + t; 69 | tv2 = t3 - t2; 70 | p->x = p1.x * tp1 + p2.x * tp2 + v1.x * tv1 + v2.x * tv2; 71 | p->y = p1.y * tp1 + p2.y * tp2 + v1.y * tv1 + v2.y * tv2; 72 | p->z = p1.z * tp1 + p2.z * tp2 + v1.z * tv1 + v2.z * tv2; 73 | } 74 | 75 | 76 | /*------------------------------------------------------------*/ 77 | void 78 | hermite_get_tangent (vector3 *v, double t) 79 | /* 80 | Return the tangent vector of the Hermite curve corresponding 81 | to the given parameter value t. 82 | */ 83 | { 84 | register double t2, tp1, tp2, tv1, tv2; 85 | 86 | /* pre */ 87 | assert (v); 88 | assert (t >= 0.0); 89 | assert (t <= 1.0); 90 | 91 | t2 = t * t; 92 | tp1 = 6.0 * (t2 - t); 93 | tp2 = 6.0 * (-t2 + t); 94 | tv1 = 3.0 * t2 - 4.0 * t + 1.0; 95 | tv2 = 3.0 * t2 - 2.0 * t; 96 | v->x = p1.x * tp1 + p2.x * tp2 + v1.x * tv1 + v2.x * tv2; 97 | v->y = p1.y * tp1 + p2.y * tp2 + v1.y * tv1 + v2.y * tv2; 98 | v->z = p1.z * tp1 + p2.z * tp2 + v1.z * tv1 + v2.z * tv2; 99 | } 100 | -------------------------------------------------------------------------------- /code/jpeg_img.c: -------------------------------------------------------------------------------- 1 | /* jpeg_img.c 2 | 3 | MolScript v2.1.2 4 | 5 | JPEG image file. 6 | 7 | This implementation is based on the Independent JPEG Group's (IJG) 8 | JPEG library (release 6a). It relies on the 'image.c' code, and 9 | therefore implicitly on OpenGL and GLX. 10 | 11 | Copyright (C) 1997-1998 Per Kraulis 12 | 9-Sep-1997 started 13 | 11-Sep-1997 working 14 | */ 15 | 16 | #include 17 | #include 18 | 19 | #include 20 | 21 | #include "jpeg_img.h" 22 | #include "global.h" 23 | #include "graphics.h" 24 | #include "image.h" 25 | #include "opengl.h" 26 | 27 | /* Must be defined at this position. */ 28 | #define HAVE_BOOLEAN 29 | #include 30 | 31 | 32 | /*============================================================*/ 33 | static int quality = 90; 34 | static struct jpeg_compress_struct cinfo; 35 | static struct jpeg_error_mgr jerr; 36 | 37 | 38 | /*------------------------------------------------------------*/ 39 | void 40 | jpgi_set (void) 41 | { 42 | ogl_set(); 43 | 44 | output_first_plot = jpgi_first_plot; 45 | output_finish_output = jpgi_finish_output; 46 | output_start_plot = ogl_start_plot_general; 47 | 48 | output_pickable = NULL; 49 | 50 | output_mode = JPEG_MODE; 51 | } 52 | 53 | 54 | /*------------------------------------------------------------*/ 55 | void 56 | jpgi_first_plot (void) 57 | { 58 | image_first_plot(); 59 | set_outfile ("wb"); 60 | 61 | cinfo.err = jpeg_std_error (&jerr); 62 | jpeg_create_compress (&cinfo); 63 | jpeg_stdio_dest (&cinfo, outfile); 64 | 65 | cinfo.image_width = output_width; 66 | cinfo.image_height = output_height; 67 | cinfo.input_components = 3; 68 | cinfo.in_color_space = JCS_RGB; 69 | jpeg_set_defaults (&cinfo); 70 | jpeg_set_quality (&cinfo, quality, TRUE); 71 | } 72 | 73 | 74 | /*------------------------------------------------------------*/ 75 | void 76 | jpgi_finish_output (void) 77 | { 78 | int row; 79 | unsigned char *buffer; 80 | 81 | image_render(); 82 | 83 | jpeg_start_compress (&cinfo, TRUE); 84 | buffer = malloc (output_width * 3 * sizeof (unsigned char)); 85 | 86 | for (row = output_height - 1; row >= 0; row--) { 87 | glReadPixels (0, row, output_width, 1, GL_RGB, GL_UNSIGNED_BYTE, buffer); 88 | jpeg_write_scanlines (&cinfo, &buffer, 1); 89 | } 90 | 91 | free (buffer); 92 | 93 | jpeg_finish_compress (&cinfo); 94 | jpeg_destroy_compress (&cinfo); 95 | 96 | image_close(); 97 | } 98 | 99 | 100 | /*------------------------------------------------------------*/ 101 | void 102 | jpgi_set_quality (int new) 103 | { 104 | assert (new > 0); 105 | assert (new <= 100); 106 | 107 | quality = new; 108 | } 109 | -------------------------------------------------------------------------------- /code/clib/err.c: -------------------------------------------------------------------------------- 1 | /* 2 | Error message procedures. The messages are written to stderr. 3 | 4 | clib v1.1 5 | 6 | Copyright (C) 1997-1998 Per Kraulis 7 | 15-May-1997 first attempts 8 | 15-Apr-1998 hgen modifications 9 | */ 10 | 11 | #include "err.h" 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | #include 18 | 19 | 20 | /*============================================================*/ 21 | static char *prefix = NULL; 22 | 23 | 24 | /*------------------------------------------------------------*/ 25 | void 26 | err_set_prefix (const char *new) 27 | /* 28 | Set the prefix (usually program name) in error messages. 29 | */ 30 | { 31 | if (prefix) free (prefix); 32 | if (new) { 33 | prefix = str_clone (new); 34 | } else { 35 | prefix = NULL; 36 | } 37 | } 38 | 39 | 40 | /*------------------------------------------------------------*/ 41 | void 42 | err_fatal (const char *msg) 43 | /* 44 | Output error message and abort execution. 45 | */ 46 | { 47 | if (prefix) { 48 | if (msg) { 49 | fprintf (stderr, "%s error: %s\n", prefix, msg); 50 | } else { 51 | fprintf (stderr, "%s error\n", prefix); 52 | } 53 | } else { 54 | if (msg) { 55 | fprintf (stderr, "Error: %s\n", msg); 56 | } else { 57 | fprintf (stderr, "Error\n"); 58 | } 59 | } 60 | exit (1); 61 | } 62 | 63 | 64 | /*------------------------------------------------------------*/ 65 | void 66 | err_message (const char *msg) 67 | /* 68 | Output error message. 69 | */ 70 | { 71 | if (prefix) { 72 | if (msg) { 73 | fprintf (stderr, "%s error: %s\n", prefix, msg); 74 | } else { 75 | fprintf (stderr, "%s error\n", prefix); 76 | } 77 | } else { 78 | if (msg) { 79 | fprintf (stderr, "Error: %s\n", msg); 80 | } else { 81 | fprintf (stderr, "Error\n"); 82 | } 83 | } 84 | } 85 | 86 | 87 | /*------------------------------------------------------------*/ 88 | void 89 | err_usage (const char *msg) 90 | /* 91 | Output usage message and abort execution. 92 | */ 93 | { 94 | /* pre */ 95 | assert (msg); 96 | 97 | if (prefix) { 98 | fprintf (stderr, "%s usage: %s\n", prefix, msg); 99 | } else { 100 | fprintf (stderr, "Usage: %s\n", msg); 101 | } 102 | exit (1); 103 | } 104 | 105 | 106 | /*------------------------------------------------------------*/ 107 | void 108 | err_warning (const char *msg) 109 | /* 110 | Output warning message. 111 | */ 112 | { 113 | if (prefix) { 114 | if (msg) { 115 | fprintf (stderr, "%s warning: %s\n", prefix, msg); 116 | } else { 117 | fprintf (stderr, "%s warning\n", prefix); 118 | } 119 | } else { 120 | if (msg) { 121 | fprintf (stderr, "Warning: %s\n", msg); 122 | } else { 123 | fprintf (stderr, "Warning\n"); 124 | } 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /docs/references.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | MolScript v2.1: References 4 | 5 | 6 | 7 | 8 | 9 |

References

10 | 11 | Adobe Systems Inc., "PostScript 12 | Language Reference Manual, Second Edition", 1990, 13 | Addison-Wesley, ISBN 0-201-18127-4. 14 |

15 | 16 | D. J. Bacon 17 | & W. F. Anderson, J. Mol. Graph. (1988) v 6, pp 219-220. 18 |

19 | 20 | A. T. Brünger, "X-PLOR, version 21 | 3.1", 1992, Yale University Press, ISBN 0-300-05402-5. 22 |

23 | 24 | R. Carey & G. Bell, "The Annotated 25 | VRML 2.0 Reference Manual", 1997, Addison-Wesley, ISBN 26 | 0-201-41974-2. 27 |

28 | 29 | J. D. Foley, A. Van Dam, S. K. Feiner 30 | & J. F. Hughes, "Fundamentals of Interactive Computer Graphics", 31 | 1990, Second Edition, Addison-Wesley, ISBN 0-201-12110-7. 32 |

33 | 34 | J. Hartman & J. Wernecke, "The 35 | VRML 2.0 Handbook", 1996, Addison-Wesley, ISBN 0-201-47944-3. 36 |

37 | 38 | W. Kabsch & C. Sander, 39 | Biopolymers (1983) v 22, pp 2577-2637. 40 |

41 | 42 | B.W. Kernighan & D.M. Ritchie, 43 | "The C Programming Language", 1988, Second Edition, Prentice 44 | Hall, ISBN 0-13-110362-8. 45 |

46 | 47 | M. J. Kilgard, "OpenGL Programming 48 | for the X Window System", 1996, Addison-Wesley, ISBN 49 | 0-201-48359-9. 50 |

51 | 52 | P. J. Kraulis, 53 | P. J. Domaille, S. L. Campbell-Burk, T. Van Aken & E. D. Laue, 54 | Biochemistry (1994) v 33, pp 3515-3531. 55 |

56 | 57 | A. M. Lesk 58 | & K. D. Hardman, Science (1982) v 216, pp 539-540. 59 |

60 | 61 | A. M. Lesk 62 | & K. D. Hardman, Methods in Enzymology (1985) v 115, pp 63 | 381-390. 64 |

65 | 66 | J. R. Levine, T. Mason & D. Brown, 67 | "lex & yacc", 1992, O'Reilly & Associates, Inc., 68 | ISBN 1-56592-000-7. 69 |

70 | 71 | E. A. Merritt 72 | & M. E. P. Murphy, Acta. Cryst. (1994) v D50, pp 869-873. 73 |

74 | 75 | J. L. Neider, T. R. Davis & 76 | M. Woo, "OpenGL Programming Guide", 1993, OpenGL Architecture 77 | Review Board, Addison-Wesley, ISBN 0-201-63274-8. 78 |

79 | 80 | J. P. Priestle, 81 | J. Appl. Cryst. (1988) v 21, pp 572-576. 82 |

83 | 84 | J. S. Richardson, 85 | Adv. Prot. Chem. (1981), v 34, pp 167-339. 86 |

87 | 88 | J. S. Richardson, 89 | Methods in Enzymology (1985) v 115, pp 359-380. 90 |

91 | 92 |


93 | Top page 94 | 95 | 96 | -------------------------------------------------------------------------------- /code/clib/named_data.c: -------------------------------------------------------------------------------- 1 | /* 2 | Named data record definition and routines. 3 | 4 | Simple storage of a memory block with a name in a node, 5 | which may be stored in a linear list of nodes. 6 | 7 | clib v1.1 8 | 9 | Copyright (C) 1998 Per Kraulis 10 | 19-Jan-1998 first attempt 11 | 3-Apr-1998 added data clone procedure 12 | */ 13 | 14 | #include "named_data.h" 15 | 16 | /* public ==================== 17 | #include 18 | 19 | #include 20 | 21 | typedef struct _named_data named_data; 22 | 23 | struct _named_data { 24 | char *name; 25 | void *data; 26 | boolean name_copy, data_copy; 27 | named_data *next; 28 | }; 29 | ==================== public */ 30 | 31 | #include 32 | #include 33 | 34 | #include 35 | 36 | 37 | /*------------------------------------------------------------*/ 38 | named_data * 39 | nd_create (char *name, boolean copy) 40 | { 41 | named_data *new = malloc (sizeof (named_data)); 42 | 43 | /* pre */ 44 | assert (name); 45 | 46 | new->name = name; 47 | new->name_copy = copy; 48 | new->data = NULL; 49 | new->data_copy = FALSE; 50 | new->next = NULL; 51 | 52 | return new; 53 | } 54 | 55 | 56 | /*------------------------------------------------------------*/ 57 | named_data * 58 | nd_set_data (named_data *nd, void *data, boolean copy) 59 | { 60 | /* pre */ 61 | assert (nd); 62 | 63 | if (nd->data && nd->data_copy) free (nd->data); 64 | nd->data = data; 65 | nd->data_copy = copy; 66 | 67 | return nd; 68 | } 69 | 70 | 71 | /*------------------------------------------------------------*/ 72 | named_data * 73 | nd_set_data_clone (named_data *nd, void *data, size_t size) 74 | { 75 | /* pre */ 76 | assert (nd); 77 | 78 | if (nd->data && nd->data_copy) free (nd->data); 79 | nd->data = memcpy (malloc (size), data, size); 80 | nd->data_copy = TRUE; 81 | 82 | return nd; 83 | } 84 | 85 | 86 | /*------------------------------------------------------------*/ 87 | void 88 | nd_delete (named_data *nd) 89 | { 90 | /* pre */ 91 | assert (nd); 92 | 93 | if (nd->next) nd_delete (nd->next); 94 | 95 | if (nd->name_copy) free (nd->name); 96 | if (nd->data && nd->data_copy) free (nd->data); 97 | free (nd); 98 | } 99 | 100 | 101 | /*------------------------------------------------------------*/ 102 | named_data * 103 | nd_append (named_data *nd, named_data *new) 104 | { 105 | /* pre */ 106 | assert (nd); 107 | assert (new); 108 | 109 | while (nd->next) nd = nd->next; 110 | nd->next = new; 111 | 112 | return new; 113 | } 114 | 115 | 116 | /*------------------------------------------------------------*/ 117 | named_data * 118 | nd_search (named_data *nd, const char *name) 119 | { 120 | /* pre */ 121 | assert (name); 122 | 123 | for ( ; nd; nd = nd->next) { 124 | assert (nd->name); 125 | if (str_eq (nd->name, name)) return nd; 126 | } 127 | 128 | return NULL; 129 | } 130 | 131 | 132 | /*------------------------------------------------------------*/ 133 | void * 134 | nd_search_data (named_data *nd, const char *name) 135 | { 136 | /* pre */ 137 | assert (name); 138 | 139 | for ( ; nd; nd = nd->next) { 140 | assert (nd->name); 141 | if (str_eq (nd->name, name)) return nd->data; 142 | } 143 | 144 | return NULL; 145 | } 146 | -------------------------------------------------------------------------------- /code/clib/key_value.c: -------------------------------------------------------------------------------- 1 | /* key_value 2 | 3 | Key/value pairs of dynstrings, storable in single-linke lists. 4 | 5 | clib v1.1 6 | 7 | Copyright (C) 1997-1998 Per Kraulis 8 | 14-Feb-1997 first attempt 9 | 4-Apr-1997 use dynstring 10 | 4-Jun-1998 mod's for hgen 11 | */ 12 | 13 | #include "key_value.h" 14 | 15 | /* public ==================== 16 | #include 17 | 18 | typedef struct s_key_value key_value; 19 | 20 | struct s_key_value { 21 | dynstring *key; 22 | dynstring *value; 23 | key_value *next; 24 | }; 25 | ==================== public */ 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | #include 32 | 33 | 34 | /*------------------------------------------------------------*/ 35 | key_value * 36 | kv_create (const char *k, const char *v) 37 | /* 38 | Create a key/value record, where the key and value are 39 | dynstring copies of the given strings. 40 | */ 41 | { 42 | key_value *new = malloc (sizeof (key_value)); 43 | 44 | new->key = ds_create (k); 45 | new->value = ds_create (v); 46 | new->next = NULL; 47 | 48 | return new; 49 | } 50 | 51 | 52 | /*------------------------------------------------------------*/ 53 | void 54 | kv_delete (key_value *kv) 55 | /* 56 | Delete this key/value record, and recursively all in the 57 | linked list from this. 58 | */ 59 | { 60 | /* pre */ 61 | assert (kv); 62 | 63 | if (kv->next) kv_delete (kv->next); 64 | ds_delete (kv->key); 65 | ds_delete (kv->value); 66 | free (kv); 67 | } 68 | 69 | 70 | /*------------------------------------------------------------*/ 71 | key_value * 72 | kv_append (key_value *kv, key_value *new) 73 | /* 74 | Append the given new key/value record to the end of the 75 | linked list from kv. The new record is returned. 76 | */ 77 | { 78 | /* pre */ 79 | assert (kv); 80 | assert (new); 81 | assert (new->next == NULL); 82 | 83 | while (kv->next) kv = kv->next; 84 | kv->next = new; 85 | 86 | return new; 87 | } 88 | 89 | 90 | /*------------------------------------------------------------*/ 91 | key_value * 92 | kv_search (key_value *first, const char *key) 93 | /* 94 | Return the key/value record from the given linked list having 95 | an equal key string as the given key. Return NULL if not found. 96 | */ 97 | { 98 | /* pre */ 99 | assert (first); 100 | assert (key); 101 | 102 | for (; first; first = first->next) { 103 | if (str_eq (first->key->string, key)) return first; 104 | } 105 | 106 | return NULL; 107 | } 108 | 109 | 110 | /*------------------------------------------------------------*/ 111 | char * 112 | kv_search_value_str (key_value *first, char *key) 113 | /* 114 | Return the value string of the key/value record from the given 115 | linked list having an equal key string as the given key. 116 | Return NULL if not found. 117 | */ 118 | { 119 | /* pre */ 120 | assert (first); 121 | assert (key); 122 | 123 | for (; first; first = first->next) { 124 | if (str_eq (first->key->string, key)) { 125 | if (first->value) { 126 | return first->value->string; 127 | } else { 128 | return NULL; 129 | } 130 | } 131 | } 132 | 133 | return NULL; 134 | } 135 | -------------------------------------------------------------------------------- /code/clib/mol3d_chain.c: -------------------------------------------------------------------------------- 1 | /* mol3d_chain 2 | 3 | Find contiguous chains of residues in 3D molecules. 4 | 5 | clib v1.1 6 | 7 | Copyright (C) 1998 Per Kraulis 8 | 8-Apr-1998 separated out from mol3d 9 | 14-Apr-1998 modified for hgen 10 | */ 11 | 12 | #include "mol3d_chain.h" 13 | 14 | #include 15 | #include 16 | 17 | /* public ==================== 18 | #include 19 | #include 20 | 21 | typedef struct s_mol3d_chain mol3d_chain; 22 | 23 | struct s_mol3d_chain { 24 | int length; 25 | res3d **residues; 26 | at3d **atoms; 27 | mol3d_chain *next; 28 | }; 29 | ==================== public */ 30 | 31 | 32 | /*------------------------------------------------------------*/ 33 | mol3d_chain * 34 | mol3d_chain_find (mol3d *first_mol, char *atomname, 35 | double cutoff, int *res_sel) 36 | /* 37 | Find all chains in the molecules, consisting of contiguous residues 38 | with an atom having the given name. Successive atoms must be within 39 | the given distance cutoff. The residue selection is optional. 40 | */ 41 | { 42 | mol3d_chain *first = NULL; 43 | mol3d_chain *prev = NULL; 44 | mol3d_chain *curr = NULL; 45 | int curr_size; 46 | mol3d *mol; 47 | res3d *res; 48 | res3d *prevres = NULL; 49 | at3d *at; 50 | at3d *prevat = NULL; 51 | double sqcutoff; 52 | 53 | /* pre */ 54 | assert (first_mol); 55 | assert (first_mol->init & MOL3D_INIT_NOBLANKS); 56 | assert (atomname); 57 | assert (*atomname); 58 | assert (cutoff > 0.0); 59 | 60 | sqcutoff = cutoff * cutoff; 61 | for (mol = first_mol; mol; mol = mol->next) { 62 | for (res = mol->first; res; res = res->next) { 63 | 64 | if ((res_sel != NULL) && /* residue selection is optional */ 65 | !(*res_sel++)) continue; 66 | 67 | at = at3d_lookup (res, atomname); 68 | if (at && prevat) { 69 | if (v3_close (&(prevat->xyz), &(at->xyz), sqcutoff)) { 70 | 71 | if (curr == NULL) { 72 | curr = malloc (sizeof (mol3d_chain)); 73 | curr_size = 128; 74 | curr->residues = malloc (curr_size * sizeof (res3d *)); 75 | curr->atoms = malloc (curr_size * sizeof (at3d *)); 76 | 77 | curr->residues[0] = prevres; 78 | curr->atoms[0] = prevat; 79 | curr->length = 1; 80 | curr->next = NULL; 81 | 82 | if (prev) { 83 | prev->next = curr; 84 | } else { 85 | first = curr; 86 | } 87 | prev = curr; 88 | 89 | } else if (curr->length >= curr_size) { 90 | curr_size *= 2; 91 | curr->residues = realloc (curr->residues, 92 | curr_size * sizeof (res3d *)); 93 | curr->atoms = realloc (curr->atoms, curr_size * sizeof (at3d *)); 94 | } 95 | 96 | curr->residues[curr->length] = res; 97 | curr->atoms[curr->length] = at; 98 | curr->length++; 99 | 100 | } else { 101 | curr = NULL; 102 | } 103 | } else { 104 | curr = NULL; 105 | } 106 | 107 | prevres = res; 108 | prevat = at; 109 | } 110 | } 111 | 112 | return first; 113 | } 114 | 115 | 116 | /*------------------------------------------------------------*/ 117 | void 118 | mol3d_chain_delete (mol3d_chain *first_ch) 119 | /* 120 | Delete this chain and its next ones. 121 | */ 122 | { 123 | /* pre */ 124 | assert (first_ch); 125 | 126 | if (first_ch->next) mol3d_chain_delete (first_ch->next); 127 | free (first_ch->residues); 128 | free (first_ch->atoms); 129 | free (first_ch); 130 | } 131 | -------------------------------------------------------------------------------- /examples/ras_vrml_lod.in: -------------------------------------------------------------------------------- 1 | ! MolScript v2.1 input file 2 | ! generated by MolAuto v1.0 3 | ! modified by hand 4 | 5 | ! VRML level-of-detail example. 6 | 7 | title "c-H-Ras p21 protein (1-166), comples with GDP, Mg" 8 | 9 | plot 10 | 11 | read mol "ras.pdb"; 12 | 13 | level-of-detail 14 | 60 { 15 | push; 16 | set segments 2, planecolour red; 17 | strand from 2 to 10; 18 | strand from 38 to 45; 19 | strand from 50 to 57; 20 | strand from 77 to 81; 21 | strand from 111 to 115; 22 | strand from 140 to 143; 23 | set segments 4, planecolour green; 24 | helix from 15 to 24; 25 | helix from 66 to 74; 26 | helix from 88 to 103; 27 | helix from 126 to 134; 28 | helix from 152 to 165; 29 | set planecolour yellow; 30 | coil from 24 to 38; 31 | coil from 57 to 66; 32 | set planecolour blue; 33 | coil from 1 to 2; 34 | turn from 10 to 15; 35 | coil from 45 to 50; 36 | coil from 74 to 77; 37 | coil from 81 to 88; 38 | coil from 103 to 111; 39 | coil from 115 to 126; 40 | coil from 134 to 140; 41 | coil from 143 to 152; 42 | coil from 165 to 166; 43 | pop; 44 | } 45 | { 46 | push; 47 | set planecolour red, segments 2, coilradius 0, strandthickness 0; 48 | strand from 2 to 10; 49 | strand from 38 to 45; 50 | strand from 50 to 57; 51 | strand from 77 to 81; 52 | strand from 111 to 115; 53 | strand from 140 to 143; 54 | set planecolour green; 55 | cylinder from 15 to 24; 56 | cylinder from 66 to 74; 57 | cylinder from 88 to 103; 58 | cylinder from 126 to 134; 59 | cylinder from 152 to 165; 60 | set planecolour yellow; 61 | coil from 24 to 38; 62 | coil from 57 to 66; 63 | set planecolour blue; 64 | coil from 1 to 2; 65 | turn from 10 to 15; 66 | coil from 45 to 50; 67 | coil from 74 to 77; 68 | coil from 81 to 88; 69 | coil from 103 to 111; 70 | coil from 115 to 126; 71 | coil from 134 to 140; 72 | coil from 143 to 152; 73 | coil from 165 to 166; 74 | }; 75 | 76 | set colourparts on; 77 | 78 | level-of-detail 79 | 16 { 80 | push; 81 | ball-and-stick require not peptide and in residue 17; 82 | set linecolour cyan; 83 | line position in type MG 84 | to position require in residue 17 and atom OG; 85 | line position in type MG 86 | to position require in type GDP and atom O1B; 87 | pop; 88 | } 89 | { }; ! Don't display Ser 17 interactions at long distance. 90 | 91 | level-of-detail 92 | 20 { 93 | push; 94 | set specularcolour white, shininess 0.2; 95 | ball-and-stick in type GDP; 96 | ball-and-stick in type MG; 97 | pop; 98 | } 99 | 30 { 100 | push; 101 | set specularcolour white, shininess 0.2; 102 | ball-and-stick in type GDP; 103 | ball-and-stick in type MG; 104 | pop; 105 | } 106 | 50 { 107 | bonds in type GDP; 108 | bonds require not hydrogens and in type HOH; 109 | bonds in type MG; 110 | } 111 | { }; ! Ligands not visible at long distance. 112 | 113 | viewpoint "GDP molecule" from position require in type GDP and atom N* 114 | to position require in type GDP and atom P* 10; 115 | 116 | viewpoint "Mg ion" from position in require type HOH 117 | and either residue 3 or residue 2 118 | to position in type MG 10; 119 | 120 | viewpoint "far away" origin position in type GDP 100; 121 | 122 | end_plot 123 | -------------------------------------------------------------------------------- /code/Makefile.basic: -------------------------------------------------------------------------------- 1 | # Makefile 2 | # 3 | # MolScript v2.1.2, basic implementation. 4 | # 5 | # This Makefile is for the most basic MolScript implementation. 6 | # It should compile on any computer system having an ANSI C compliant 7 | # compiler and system. No external libraries or systems apart from 8 | # those present in the clib directory (which is part of the MolScript 9 | # distribution) are needed. 10 | # 11 | # If you wish to compile a more complete MolScript implementation, 12 | # then look at the Makefile.complete file instead. 13 | # 14 | # See the documentation for more information. 15 | # 16 | # Copyright (C) 1997-1998 Per Kraulis 17 | # 1-Dec-1996 first attempts 18 | # 13-Sep-1997 rearranged optional implementations 19 | # 22-Oct-1997 modified for distribution 20 | # 19-Nov-1997 checked for distribution 21 | # 15-Aug-1998 reorganized for v2.1 22 | # 1-Nov-2014 rearranged directories for GitHub 23 | 24 | # Executables 25 | MOLSCRIPT = ../molscript 26 | MOLAUTO = ../molauto 27 | 28 | # Command execution shell. 29 | SHELL = /bin/sh 30 | 31 | # GNU's cc compiler. 32 | CC = gcc 33 | # optimization flags: 34 | COPT = -O 35 | # correctness flags: 36 | #CCHECK = -DNDEBUG 37 | 38 | # General cc compile flags. 39 | CFLAGS = $(COPT) $(CCHECK) -Iclib 40 | 41 | # GNU's bison; required instead of the ordinary yacc. 42 | YACC = bison 43 | YFLAGS = -d 44 | YLIB = 45 | 46 | #------------------------------------------------------------ 47 | OBJ = molscript.tab.o global.o lex.o col.o select.o \ 48 | state.o graphics.o segment.o coord.o xform.o \ 49 | postscript.o raster3d.o vrml.o regex.o 50 | 51 | #------------------------------------------------------------ 52 | all: $(MOLSCRIPT) $(MOLAUTO) 53 | 54 | #------------------------------------------------------------ 55 | clean: 56 | (rm -f $(MOLSCRIPT) $(MOLAUTO) *.o core *~) 57 | (cd clib; make clean) 58 | 59 | #------------------------------------------------------------ 60 | $(MOLSCRIPT): $(OBJ) clib/clib.a 61 | $(CC) $(OPT) -o $(MOLSCRIPT) $(OBJ) $(YLIB) clib/clib.a -lm 62 | 63 | molscript.tab.o: molscript.tab.c molscript.tab.h 64 | 65 | molscript.tab.c molscript.tab.h: molscript.y 66 | $(YACC) $(YFLAGS) molscript.y 67 | 68 | global.o: global.c global.h lex.h state.h graphics.h xform.h \ 69 | postscript.h raster3d.h vrml.h 70 | 71 | lex.o: lex.c lex.h global.h molscript.tab.h 72 | 73 | col.o: col.c col.h global.h lex.h state.h 74 | 75 | select.o: select.c select.h coord.h global.h state.h lex.h 76 | 77 | state.o: state.c state.h col.h global.h select.h 78 | 79 | graphics.o: graphics.c graphics.h coord.h state.h global.h lex.h \ 80 | select.h xform.h segment.h postscript.h raster3d.h vrml.h 81 | 82 | segment.o: segment.c segment.h 83 | 84 | coord.o: coord.c coord.h global.h lex.h select.h 85 | 86 | xform.o: xform.c xform.h global.h select.h 87 | 88 | postscript.o: postscript.c postscript.h coord.h global.h \ 89 | graphics.h segment.h state.h 90 | 91 | raster3d.o: raster3d.c raster3d.h coord.h global.h graphics.h segment.h state.h 92 | 93 | vrml.o: vrml.c vrml.h col.h coord.h global.h graphics.h segment.h state.h 94 | 95 | regex.o: other/regex.c 96 | $(CC) $(CFLAGS) -c -o ./regex.o other/regex.c 97 | 98 | #------------------------------------------------------------ 99 | $(MOLAUTO): molauto.o clib/clib.a 100 | $(CC) -o $(MOLAUTO) molauto.o clib/clib.a -lm 101 | 102 | molauto.o: molauto.c 103 | 104 | #------------------------------------------------------------ 105 | clib/clib.a: 106 | cd clib; make clib.a CFLAGS="-I. $(CFLAGS)" 107 | -------------------------------------------------------------------------------- /code/graphics.h: -------------------------------------------------------------------------------- 1 | /* graphics.h 2 | 3 | MolScript v2.1.2 4 | 5 | Graphics: construct the geometries and call the output procedures. 6 | 7 | Copyright (C) 1997-1998 Per Kraulis 8 | 6-Dec-1996 first attempts 9 | */ 10 | 11 | #ifndef GRAPHICS_H 12 | #define GRAPHICS_H 1 13 | 14 | #include "coord.h" 15 | #include "state.h" 16 | 17 | enum object_codes {OBJ_POINTS, OBJ_POINTS_COLOURS, 18 | OBJ_LINES, OBJ_LINES_COLOURS, 19 | OBJ_TRIANGLES, OBJ_TRIANGLES_COLOURS, OBJ_TRIANGLES_NORMALS, 20 | OBJ_TRIANGLES_NORMALS_COLOURS, 21 | OBJ_STRIP, OBJ_STRIP_COLOURS, OBJ_STRIP_NORMALS, 22 | OBJ_STRIP_NORMALS_COLOURS }; 23 | 24 | #define LINEWIDTH_FACTOR 0.04 25 | #define LINEWIDTH_MINIMUM 0.005 26 | 27 | extern boolean frame; 28 | extern double area [4]; 29 | extern colour background_colour; 30 | extern double window; 31 | extern double slab; 32 | extern boolean headlight; 33 | extern boolean shadows; 34 | extern double fog; 35 | extern double dynamics_time; 36 | 37 | extern double aspect_ratio; 38 | extern double aspect_window_x, aspect_window_y; 39 | 40 | extern void (*output_first_plot) (void); 41 | extern void (*output_start_plot) (void); 42 | extern void (*output_finish_plot) (void); 43 | extern void (*output_finish_output) (void); 44 | 45 | extern void (*set_area) (void); 46 | extern void (*set_background) (void); 47 | extern void (*anchor_start) (char *str); 48 | extern void (*anchor_description) (char *str); 49 | extern void (*anchor_parameter) (char *str); 50 | extern void (*anchor_start_geometry) (void); 51 | extern void (*anchor_finish) (void); 52 | extern void (*lod_start) (void); 53 | extern void (*lod_finish) (void); 54 | extern void (*lod_start_group) (void); 55 | extern void (*lod_finish_group) (void); 56 | extern void (*viewpoint_start) (char *str); 57 | extern void (*viewpoint_output) (void); 58 | extern void (*output_directionallight) (void); 59 | extern void (*output_pointlight) (void); 60 | extern void (*output_spotlight) (void); 61 | extern void (*output_comment) (char *str); 62 | 63 | extern void (*output_coil) (void); 64 | extern void (*output_cylinder) (vector3 *v1, vector3 *v2); 65 | extern void (*output_helix) (void); 66 | extern void (*output_label) (vector3 *p, char *label, colour *c); 67 | extern void (*output_line) (boolean polylines); 68 | extern void (*output_sphere) (at3d *at, double radius); 69 | extern void (*output_stick) (vector3 *v1, vector3 *v2, 70 | double r1, double r2, colour *c); 71 | extern void (*output_strand) (void); 72 | 73 | extern void (*output_start_object) (void); 74 | extern void (*output_object) (int code, vector3 *triplets, int count); 75 | extern void (*output_finish_object) (void); 76 | 77 | extern void (*output_pickable) (at3d *atom); 78 | 79 | void graphics_plot_init (void); 80 | void set_area_values (double xlo, double ylo, double xhi, double yhi); 81 | void set_window (void); 82 | void set_slab (void); 83 | void set_fog (void); 84 | 85 | void set_extent (void); 86 | int outside_extent_radius (vector3 *v, double radius); 87 | int outside_extent_2v (vector3 *v1, vector3 *v2); 88 | 89 | double depthcue (double depth, state *st); 90 | 91 | void ball_and_stick (int single_selection); 92 | void bonds (int single_selection); 93 | void coil (int is_peptide_chain, int smoothing); 94 | void cpk (void); 95 | void cylinder (void); 96 | void helix (void); 97 | void label_atoms (char *label); 98 | void label_position (char *label); 99 | void line_start (void); 100 | void line_next (void); 101 | void object (char *filename); 102 | void strand (void); 103 | void trace (void); 104 | 105 | #endif 106 | -------------------------------------------------------------------------------- /code/state.h: -------------------------------------------------------------------------------- 1 | /* state.h 2 | 3 | MolScript v2.1.2 4 | 5 | Graphics state. 6 | 7 | Copyright (C) 1997-1998 Per Kraulis 8 | 4-Dec-1996 first attempts 9 | 2-Jan-1997 largely finished 10 | 26-Apr-1998 push and pop implemented 11 | */ 12 | 13 | #ifndef STATE_H 14 | #define STATE_H 1 15 | 16 | #include "clib/vector3.h" 17 | 18 | #include "col.h" 19 | 20 | typedef struct s_state state; 21 | 22 | struct s_state { 23 | state *prev; 24 | double bonddistance; 25 | double bondcross; 26 | double coilradius; 27 | boolean colourparts; 28 | double cylinderradius; 29 | double depthcue; 30 | colour emissivecolour; 31 | double helixthickness; 32 | double helixwidth; 33 | boolean hsbramp; 34 | boolean hsbrampreverse; 35 | double labelbackground; 36 | boolean labelcentre; 37 | boolean labelclip; 38 | int *labelmask; 39 | int labelmasklength; 40 | vector3 labeloffset; 41 | boolean labelrotation; 42 | double labelsize; 43 | double lightambientintensity; 44 | vector3 lightattenuation; 45 | colour lightcolour; 46 | double lightintensity; 47 | double lightradius; 48 | colour linecolour; 49 | double linedash; 50 | double linewidth; 51 | boolean objecttransform; 52 | colour planecolour; 53 | colour plane2colour; 54 | boolean regularexpression; 55 | int segments; 56 | double segmentsize; 57 | double shading; 58 | double shadingexponent; 59 | double shininess; 60 | int smoothsteps; 61 | colour specularcolour; 62 | double splinefactor; 63 | double stickradius; 64 | double sticktaper; 65 | double strandthickness; 66 | double strandwidth; 67 | double transparency; 68 | }; 69 | 70 | extern state *current_state; 71 | 72 | void state_init (void); 73 | void new_state (void); 74 | void push_state (void); 75 | void pop_state (void); 76 | 77 | void set_atomcolour (void); 78 | void set_atomcolour_bfactor (void); 79 | void set_atomradius (void); 80 | void set_bonddistance (void); 81 | void set_bondcross (void); 82 | void set_coilradius (void); 83 | void set_colourparts (boolean on); 84 | void set_colourramphsb (boolean hsb); 85 | void set_cylinderradius (void); 86 | void set_depthcue (void); 87 | void set_emissivecolour (void); 88 | void set_helixthickness (void); 89 | void set_helixwidth (void); 90 | void set_hsbrampreverse (boolean on); 91 | void set_labelbackground (void); 92 | void set_labelcentre (boolean on); 93 | void set_labelclip (boolean on); 94 | void set_labelmask (const char *str); 95 | void set_labeloffset (void); 96 | void set_labelrotation (boolean on); 97 | void set_labelsize (void); 98 | void set_lightambientintensity (void); 99 | void set_lightattenuation (void); 100 | void set_lightcolour (void); 101 | void set_lightintensity (void); 102 | void set_lightradius (void); 103 | void set_linecolour (void); 104 | void set_linedash (void); 105 | void set_linewidth (void); 106 | void set_objecttransform (boolean on); 107 | void set_planecolour (void); 108 | void set_plane2colour (void); 109 | void set_residuecolour (void); 110 | void set_residuecolour_bfactor (void); 111 | void set_residuecolour_seq (void); 112 | void set_regularexpression (boolean on); 113 | void set_segments (void); 114 | void set_segmentsize (void); 115 | void set_shading (void); 116 | void set_shadingexponent (void); 117 | void set_shininess (void); 118 | void set_smoothsteps (void); 119 | void set_specularcolour (void); 120 | void set_splinefactor (void); 121 | void set_stickradius (void); 122 | void set_sticktaper (void); 123 | void set_strandthickness (void); 124 | void set_strandwidth (void); 125 | void set_transparency (void); 126 | 127 | #endif 128 | -------------------------------------------------------------------------------- /code/segment.c: -------------------------------------------------------------------------------- 1 | /* segment.c 2 | 3 | MolScript v2.1.2 4 | 5 | Segment data structure and routines. 6 | 7 | Copyright (C) 1997-1998 Per Kraulis 8 | 18-Aug-1997 split out of vrml.c; generalized 9 | */ 10 | 11 | #include 12 | 13 | #include "segment.h" 14 | 15 | 16 | /*------------------------------------------------------------*/ 17 | line_segment *line_segments = NULL; 18 | int line_segment_count; 19 | static int line_segment_alloc; 20 | 21 | strand_segment *strand_segments = NULL; 22 | int strand_segment_count; 23 | static int strand_segment_alloc; 24 | 25 | helix_segment *helix_segments = NULL; 26 | int helix_segment_count; 27 | static int helix_segment_alloc; 28 | 29 | coil_segment *coil_segments = NULL; 30 | int coil_segment_count; 31 | static int coil_segment_alloc; 32 | 33 | 34 | /*------------------------------------------------------------*/ 35 | void 36 | line_segment_init (void) 37 | { 38 | if (line_segments == NULL) { 39 | line_segment_alloc = 512; 40 | line_segments = malloc (line_segment_alloc * sizeof (line_segment)); 41 | } 42 | line_segment_count = 0; 43 | } 44 | 45 | 46 | /*------------------------------------------------------------*/ 47 | line_segment * 48 | line_segment_next (void) 49 | { 50 | line_segment *new; 51 | 52 | if (line_segment_count >= line_segment_alloc) { 53 | line_segment_alloc *= 2; 54 | line_segments = realloc (line_segments, 55 | line_segment_alloc * sizeof (line_segment)); 56 | } 57 | new = &(line_segments[line_segment_count++]); 58 | new->new = FALSE; 59 | return new; 60 | } 61 | 62 | 63 | /*------------------------------------------------------------*/ 64 | void 65 | strand_segment_init (void) 66 | { 67 | if (strand_segments == NULL) { 68 | strand_segment_alloc = 256; 69 | strand_segments = malloc (strand_segment_alloc * sizeof (strand_segment)); 70 | } 71 | strand_segment_count = 0; 72 | } 73 | 74 | 75 | /*------------------------------------------------------------*/ 76 | strand_segment * 77 | strand_segment_next (void) 78 | { 79 | if (strand_segment_count >= strand_segment_alloc) { 80 | strand_segment_alloc *= 2; 81 | strand_segments = realloc (strand_segments, 82 | strand_segment_alloc * sizeof (strand_segment)); 83 | } 84 | return &(strand_segments[strand_segment_count++]); 85 | } 86 | 87 | 88 | /*------------------------------------------------------------*/ 89 | void 90 | helix_segment_init (void) 91 | { 92 | if (helix_segments == NULL) { 93 | helix_segment_alloc = 512; 94 | helix_segments = malloc (helix_segment_alloc * sizeof (helix_segment)); 95 | } 96 | helix_segment_count = 0; 97 | } 98 | 99 | 100 | /*------------------------------------------------------------*/ 101 | helix_segment * 102 | helix_segment_next (void) 103 | { 104 | if (helix_segment_count >= helix_segment_alloc) { 105 | helix_segment_alloc *= 2; 106 | helix_segments = realloc (helix_segments, 107 | helix_segment_alloc * sizeof (helix_segment)); 108 | } 109 | return &(helix_segments[helix_segment_count++]); 110 | } 111 | 112 | 113 | /*------------------------------------------------------------*/ 114 | void 115 | coil_segment_init (void) 116 | { 117 | if (coil_segments == NULL) { 118 | coil_segment_alloc = 512; 119 | coil_segments = malloc (coil_segment_alloc * sizeof (coil_segment)); 120 | } 121 | coil_segment_count = 0; 122 | } 123 | 124 | 125 | /*------------------------------------------------------------*/ 126 | coil_segment * 127 | coil_segment_next (void) 128 | { 129 | if (coil_segment_count >= coil_segment_alloc) { 130 | coil_segment_alloc *= 2; 131 | coil_segments = realloc (coil_segments, 132 | coil_segment_alloc * sizeof (coil_segment)); 133 | } 134 | return &(coil_segments[coil_segment_count++]); 135 | } 136 | -------------------------------------------------------------------------------- /code/molscript.tab.h: -------------------------------------------------------------------------------- 1 | #ifndef YYSTYPE 2 | #define YYSTYPE int 3 | #endif 4 | #define INTEGER 258 5 | #define REAL 259 6 | #define STRING 260 7 | #define ITEM 261 8 | #define ON 262 9 | #define OFF 263 10 | #define POSITION 264 11 | #define TITLE 265 12 | #define MACRO 266 13 | #define PLOT 267 14 | #define END_PLOT 268 15 | #define COMMENT 269 16 | #define DEBUG 270 17 | #define POSTSCRIPT 271 18 | #define RASTER3D 272 19 | #define VRML 273 20 | #define NOFRAME 274 21 | #define FRAME 275 22 | #define AREA 276 23 | #define BACKGROUND 277 24 | #define WINDOW 278 25 | #define SLAB 279 26 | #define HEADLIGHT 280 27 | #define SHADOWS 281 28 | #define FOG 282 29 | #define READ 283 30 | #define INLINE_PDB 284 31 | #define DELETE 285 32 | #define COPY 286 33 | #define ANCHOR 287 34 | #define DESCRIPTION 288 35 | #define PARAMETER 289 36 | #define VIEWPOINT 290 37 | #define ORIGIN 291 38 | #define DIRECTIONALLIGHT 292 39 | #define POINTLIGHT 293 40 | #define SPOTLIGHT 294 41 | #define LEVEL_OF_DETAIL 295 42 | #define TRANSFORM 296 43 | #define BY 297 44 | #define CENTRE 298 45 | #define TRANSLATION 299 46 | #define ROTATION 300 47 | #define XAXIS 301 48 | #define YAXIS 302 49 | #define ZAXIS 303 50 | #define AXIS 304 51 | #define STORE_MATRIX 305 52 | #define RECALL_MATRIX 306 53 | #define NOT 307 54 | #define REQUIRE 308 55 | #define AND 309 56 | #define EITHER 310 57 | #define OR 311 58 | #define BACKBONE 312 59 | #define PEPTIDE 313 60 | #define HYDROGENS 314 61 | #define ATOM 315 62 | #define RES_ATOM 316 63 | #define B_FACTOR 317 64 | #define OCCUPANCY 318 65 | #define IN 319 66 | #define SPHERE 320 67 | #define CLOSE 321 68 | #define MODEL 322 69 | #define AMINO_ACIDS 323 70 | #define WATERS 324 71 | #define NUCLEOTIDES 325 72 | #define LIGANDS 326 73 | #define MOLECULE 327 74 | #define FROM 328 75 | #define TO 329 76 | #define RESIDUE 330 77 | #define TYPE 331 78 | #define CONTAINS 332 79 | #define CHAIN 333 80 | #define ELEMENT 334 81 | #define SEGID 335 82 | #define SET 336 83 | #define PUSH 337 84 | #define POP 338 85 | #define ATOMCOLOUR 339 86 | #define ATOMRADIUS 340 87 | #define BONDDISTANCE 341 88 | #define BONDCROSS 342 89 | #define COILRADIUS 343 90 | #define COLOURPARTS 344 91 | #define COLOURRAMP 345 92 | #define CYLINDERRADIUS 346 93 | #define DEPTHCUE 347 94 | #define EMISSIVECOLOUR 348 95 | #define HELIXTHICKNESS 349 96 | #define HELIXWIDTH 350 97 | #define HSBRAMPREVERSE 351 98 | #define LABELBACKGROUND 352 99 | #define LABELCENTRE 353 100 | #define LABELCLIP 354 101 | #define LABELMASK 355 102 | #define LABELOFFSET 356 103 | #define LABELROTATION 357 104 | #define LABELSIZE 358 105 | #define LIGHTAMBIENTINTENSITY 359 106 | #define LIGHTATTENUATION 360 107 | #define LIGHTCOLOUR 361 108 | #define LIGHTINTENSITY 362 109 | #define LIGHTRADIUS 363 110 | #define LINECOLOUR 364 111 | #define LINEDASH 365 112 | #define LINEWIDTH 366 113 | #define OBJECTTRANSFORM 367 114 | #define PLANECOLOUR 368 115 | #define PLANE2COLOUR 369 116 | #define REGULAREXPRESSION 370 117 | #define RESIDUECOLOUR 371 118 | #define SEGMENTS 372 119 | #define SEGMENTSIZE 373 120 | #define SHADING 374 121 | #define SHADINGEXPONENT 375 122 | #define SHININESS 376 123 | #define SMOOTHSTEPS 377 124 | #define SPECULARCOLOUR 378 125 | #define SPLINEFACTOR 379 126 | #define STICKRADIUS 380 127 | #define STICKTAPER 381 128 | #define STRANDTHICKNESS 382 129 | #define STRANDWIDTH 383 130 | #define TRANSPARENCY 384 131 | #define BALL_AND_STICK 385 132 | #define BONDS 386 133 | #define COIL 387 134 | #define CYLINDER 388 135 | #define CPK 389 136 | #define HELIX 390 137 | #define LABEL 391 138 | #define LINE 392 139 | #define OBJECT 393 140 | #define INLINE 394 141 | #define STRAND 395 142 | #define TRACE 396 143 | #define TURN 397 144 | #define DOUBLE_HELIX 398 145 | #define RGB 399 146 | #define HSB 400 147 | #define GREY 401 148 | #define RAINBOW 402 149 | 150 | 151 | extern YYSTYPE yylval; 152 | -------------------------------------------------------------------------------- /docs/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | MolScript v2.1: Documentation 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | ras_std 13 | 14 | 15 | ras_rmsd 16 | 17 | 18 |

MolScript v2.1

19 | 20 |

Documentation

21 | 22 | Copyright © 1997-1998 Per Kraulis 23 |

24 | The Official MolScript Web Site 25 |

26 | The MolScript GitHub repository 27 |

28 | 29 |
30 | 31 |

32 | 33 |
34 | MolScript is a program for creating schematic or detailed molecular 35 | graphics images from molecular 3D coordinates, usually, but not 36 | exclusively, protein structures. The user supplies an input file (the 37 | script) which specifies the coordinate file, what objects to render 38 | and the exact appearance of the objects through the graphics state 39 | parameters. There is a helper program 40 | MolAuto, which produces a good 41 | first-approximation input file from a coordinate file. 42 | 43 |
44 | 45 | 46 | 47 | 80 | 81 | 109 | 110 | 111 |
48 | 79 | 82 | 108 |
112 | 113 |
114 | 115 | 116 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | MolScript v2.1.2 2 | ================ 3 | 4 | Copyright (C) 1997-1998 Per J. Kraulis 5 | 6 | 7 | 8 | 11 | 14 | 17 | 18 |
9 | 10 | 12 | 13 | 15 | 16 |
19 | 20 | MolScript is a program for displaying molecular 3D structures, such as 21 | proteins, in both schematic and detailed representations. 22 | 23 | The documentation is at [http://pekrau.github.io/MolScript/](http://pekrau.github.io/MolScript/). 24 | 25 | Background 26 | ---------- 27 | 28 | MolScript has for a long time been a standard tool in the science of 29 | macromolecular structures. [The paper describing 30 | it](http://dx.doi.org/10.1107/S0021889891004399 "MOLSCRIPT: a program 31 | to produce both detailed and schematic plots of protein structures.") 32 | appears as number 82 in the list of the Nature feature article ["The 33 | Top 100 Papers. Nature explores the most-cited research of all 34 | time"](http://www.nature.com/news/the-top-100-papers-1.16224) by 35 | Richard Van Noorden, Brendan Maher & Regina Nuzzo published [30 Oct 36 | 2014](http://www.nature.com/nature/journal/v514/n7524/index.html). 37 | 38 | I have written a blog post [MolScript: A story of success and 39 | failure](http://kraulis.wordpress.com/2014/11/03/molscript-a-story-of-success-and-failure/), 40 | describing the history behind its rise and fall. 41 | 42 | Open Source 43 | ----------- 44 | 45 | MolScript is now available under the MIT license from this GitHub 46 | repository. I have for a long time intended to make MolScript Open 47 | Source, but never got around to it. The Nature Top-100-list did the 48 | trick of pushing me into action. 49 | 50 | Version 2.1.2 51 | ------------- 52 | 53 | The first version of MolScript (written in Fortran 77) was released in 54 | 1991, and its current version (2.1.2, written in C) in 1998. 55 | 56 | Please be aware that no changes have been made to the code since 57 | 1998. In particular, the Makefile for the executable including OpenGL 58 | support is not up to scratch. It needs updating. If anyone is willing to 59 | help, I would much appreciate it. 60 | 61 | I have tested the `Makefile.basic` file, which builds an executable 62 | with support for PostScript, Raster3D and VRML. It works, at least on 63 | Ubuntu 12.04. I have also verified that the [Raster3D software 64 | (v3.0)](http://skuld.bmsc.washington.edu/raster3d/html/raster3d.html) 65 | still works with MolScript. 66 | 67 | Future plans 68 | ------------ 69 | 70 | I have very little time to work on MolScript currently. Other projects 71 | are more pressing. If anyone is willing to "take over" (i.e. fork) and 72 | continue developing MolScript, I would be very pleased. 73 | 74 | Here are some possible items for a roadmap for future development of MolScript: 75 | 76 | * Fix the OpenGL implementation, with a working Makefile. 77 | 78 | * Prepare a proper Debian package for easier installation. 79 | 80 | * Add a proper interactive interface to the OpenGL implementation. The 81 | script language was nice once upon a time, but today it must be 82 | considered as user-hostile and cumbersome. 83 | 84 | * Write an implementation to produce 85 | [X3D](http://www.web3d.org/x3d/what-x3d), the successor to the VRML 86 | format for 3D objects on the web. 87 | 88 | * Write a [WebGL](http://en.wikipedia.org/wiki/WebGL) implementation. 89 | 90 | * Set up a web service producing images from input scripts using MolScript. 91 | 92 | 93 | Reference 94 | --------- 95 | 96 | Per J. Kraulis 97 | MOLSCRIPT: a program to produce both detailed and schematic plots of 98 | protein structures. 99 | J. Appl. Cryst. (1991) 24, 946-950 100 | 101 | This paper is now available under Open Access: [PDF](docs/kraulis_1991_molscript_j_appl_cryst.pdf) 102 | 103 | [DOI:10.1107/S0021889891004399](http://dx.doi.org/10.1107/S0021889891004399) 104 | 105 | [Entry at J. Appl. Cryst. web site](http://scripts.iucr.org/cgi-bin/paper?S0021889891004399) 106 | 107 | -------------------------------------------------------------------------------- /code/png_img.c: -------------------------------------------------------------------------------- 1 | /* png_img.c 2 | 3 | MolScript v2.1.2 4 | 5 | PNG image. 6 | 7 | This implementation is based on the PNG Reference Library 1.0 8 | version 0.96 and zlib v1.0.4. It relies on the 'image.c' code, 9 | and therefore implicitly on OpenGL and GLX. 10 | 11 | Copyright (C) 1997-1998 Per Kraulis 12 | 12-Sep-1997 started 13 | 21-Dec-1997 identified minor memory leak in PNG library; not fixed 14 | */ 15 | 16 | #include 17 | #include 18 | 19 | #include 20 | 21 | #include 22 | 23 | #include "clib/str_utils.h" 24 | #include "clib/dynstring.h" 25 | 26 | #include "png_img.h" 27 | #include "global.h" 28 | #include "graphics.h" 29 | #include "image.h" 30 | #include "opengl.h" 31 | 32 | 33 | /*============================================================*/ 34 | static int compression_level = Z_DEFAULT_COMPRESSION; 35 | static png_structp png_ptr; 36 | static png_infop info_ptr; 37 | static png_text text_ptr[4]; 38 | 39 | 40 | /*------------------------------------------------------------*/ 41 | void 42 | pngi_set (void) 43 | { 44 | ogl_set(); 45 | 46 | output_first_plot = pngi_first_plot; 47 | output_finish_output = pngi_finish_output; 48 | output_start_plot = ogl_start_plot_general; 49 | 50 | output_pickable = NULL; 51 | 52 | output_mode = PNG_MODE; 53 | } 54 | 55 | 56 | /*------------------------------------------------------------*/ 57 | void 58 | pngi_first_plot (void) 59 | { 60 | int count = 0; 61 | dynstring *software_info; 62 | 63 | image_first_plot(); 64 | set_outfile ("wb"); 65 | 66 | png_ptr = png_create_write_struct (PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); 67 | if (png_ptr == NULL) 68 | yyerror ("png_img: could not create PNG image structure"); 69 | info_ptr = png_create_info_struct (png_ptr); 70 | if (info_ptr == NULL) 71 | yyerror ("png_img: could not create PNG info structure"); 72 | if (setjmp (png_ptr->jmpbuf)) yyerror ("png_img: could not setjmp"); 73 | 74 | png_init_io (png_ptr, outfile); 75 | png_set_compression_level (png_ptr, compression_level); 76 | png_set_IHDR (png_ptr, info_ptr, output_width, output_height, 8, 77 | PNG_COLOR_TYPE_RGB, NULL, NULL, NULL); 78 | 79 | if (title) { 80 | text_ptr[count].key = "Title"; 81 | text_ptr[count].text = title; 82 | text_ptr[count++].compression = PNG_TEXT_COMPRESSION_NONE; 83 | } 84 | text_ptr[count].key = "Software"; 85 | software_info = ds_create (program_str); 86 | ds_cat (software_info, ", "); 87 | ds_cat (software_info, copyright_str); 88 | text_ptr[count].text = software_info->string; 89 | text_ptr[count++].compression = PNG_TEXT_COMPRESSION_NONE; 90 | if (user_str[0] != '\0') { 91 | text_ptr[count].key = "Author"; 92 | text_ptr[count].text = user_str; 93 | text_ptr[count++].compression = PNG_TEXT_COMPRESSION_NONE; 94 | } 95 | png_set_text (png_ptr, info_ptr, text_ptr, count); 96 | 97 | png_write_info (png_ptr, info_ptr); 98 | 99 | ds_delete (software_info); 100 | } 101 | 102 | 103 | /*------------------------------------------------------------*/ 104 | void 105 | pngi_finish_output (void) 106 | { 107 | int row; 108 | unsigned char *buffer; /* this ought to be png_bytep? */ 109 | 110 | image_render(); 111 | 112 | buffer = malloc (output_width * 3 * sizeof (unsigned char)); 113 | 114 | for (row = output_height - 1; row >= 0; row--) { 115 | glReadPixels (0, row, output_width, 1, GL_RGB, GL_UNSIGNED_BYTE, buffer); 116 | png_write_row (png_ptr, (png_bytep) buffer); 117 | } 118 | 119 | free (buffer); 120 | 121 | png_write_end (png_ptr, NULL); 122 | png_destroy_write_struct (&png_ptr, &info_ptr); 123 | 124 | image_close(); 125 | } 126 | 127 | 128 | /*------------------------------------------------------------*/ 129 | int 130 | pngi_set_compression (char *level) 131 | { 132 | assert (level); 133 | assert (*level); 134 | 135 | if (str_eq (level, "default")) { 136 | compression_level = Z_DEFAULT_COMPRESSION; 137 | } else if (str_eq (level, "speed")) { 138 | compression_level = Z_BEST_SPEED; 139 | } else if (str_eq (level, "size")) { 140 | compression_level = Z_BEST_COMPRESSION; 141 | } else if (str_eq (level, "none")) { 142 | compression_level = Z_NO_COMPRESSION; 143 | } else { 144 | return FALSE; 145 | } 146 | return TRUE; 147 | } 148 | -------------------------------------------------------------------------------- /code/clib/mol3d.h: -------------------------------------------------------------------------------- 1 | #ifndef MOL3D_H 2 | #define MOL3D_H 1 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #define RES3D_NAME_LENGTH 6 10 | #define RES3D_TYPE_LENGTH 4 11 | #define RES3D_SEGID_LENGTH 4 12 | #define AT3D_NAME_LENGTH 4 13 | 14 | typedef struct s_mol3d mol3d; 15 | typedef struct s_res3d res3d; 16 | typedef struct s_at3d at3d; 17 | 18 | struct s_mol3d { 19 | unsigned int unique; 20 | char *name; 21 | int model; 22 | res3d *first; 23 | mol3d *next; 24 | unsigned int init; 25 | named_data *data; 26 | }; 27 | 28 | struct s_res3d { 29 | unsigned int unique; 30 | char name [RES3D_NAME_LENGTH + 1]; 31 | char type [RES3D_TYPE_LENGTH + 1]; 32 | char segid [RES3D_SEGID_LENGTH + 1]; 33 | int ordinal; 34 | char chain, code, secstruc; 35 | boolean heterogen; 36 | double accessibility; 37 | colour colour; 38 | at3d *central; 39 | res3d *beta1, *beta2; 40 | res3d *prev, *next; 41 | at3d *first; 42 | mol3d *mol; 43 | named_data *data; 44 | }; 45 | 46 | struct s_at3d { 47 | unsigned int unique; 48 | char name [AT3D_NAME_LENGTH + 1]; 49 | int element; 50 | int ordinal; 51 | char altloc; 52 | vector3 xyz; 53 | double occupancy, bfactor, radius, charge, accessibility, rval; 54 | colour colour; 55 | at3d *next; 56 | res3d *res; 57 | named_data *data; 58 | }; 59 | 60 | #define MOL3D_INIT_NOBLANKS 0x00000001 61 | #define MOL3D_INIT_COLOURS 0x00000002 62 | #define MOL3D_INIT_RADII 0x00000004 63 | #define MOL3D_INIT_AACODES 0x00000008 64 | #define MOL3D_INIT_CENTRALS 0x00000010 65 | #define MOL3D_INIT_RESIDUE_ORDINALS 0x00000020 66 | #define MOL3D_INIT_ATOM_ORDINALS 0x00000040 67 | #define MOL3D_INIT_ELEMENTS 0x00000080 68 | #define MOL3D_INIT_SECSTRUC 0x00000100 69 | #define MOL3D_INIT_ACCESS 0x00000200 70 | 71 | mol3d * 72 | mol3d_create (void); 73 | 74 | res3d * 75 | res3d_create (void); 76 | 77 | at3d * 78 | at3d_create (void); 79 | 80 | res3d * 81 | res3d_clone (res3d *res); 82 | 83 | at3d * 84 | at3d_clone (at3d *at); 85 | 86 | void 87 | mol3d_delete (mol3d *mol); 88 | 89 | void 90 | mol3d_delete_all (mol3d *first_mol); 91 | 92 | void 93 | res3d_delete (res3d *res); 94 | 95 | void 96 | at3d_delete (at3d *at); 97 | 98 | void 99 | mol3d_set_name (mol3d *mol, const char *name); 100 | 101 | mol3d * 102 | mol3d_append (mol3d *first_mol, mol3d *new); 103 | 104 | res3d * 105 | res3d_add (res3d *res, res3d *new); 106 | 107 | at3d * 108 | at3d_add (at3d *at, at3d *new); 109 | 110 | res3d * 111 | mol3d_append_residue (mol3d *mol, res3d *res); 112 | 113 | at3d * 114 | res3d_append_atom (res3d *res, at3d *at); 115 | 116 | named_data * 117 | mol3d_create_named_data (mol3d *mol, char *name, boolean ncopy, 118 | void *data, boolean dcopy); 119 | 120 | named_data * 121 | res3d_create_named_data (res3d *res, char *name, boolean ncopy, 122 | void *data, boolean dcopy); 123 | 124 | named_data * 125 | at3d_create_named_data (at3d *at, char *name, boolean ncopy, 126 | void *data, boolean dcopy); 127 | 128 | boolean 129 | mol3d_remove_molecule (mol3d *mol1, mol3d *mol2); 130 | 131 | boolean 132 | mol3d_remove_residue (mol3d *mol, res3d *res); 133 | 134 | boolean 135 | res3d_remove_atom (res3d *res, at3d *at); 136 | 137 | int 138 | mol3d_count (mol3d *first_mol); 139 | 140 | int 141 | mol3d_count_residues (mol3d *mol); 142 | 143 | int 144 | mol3d_count_residues_all (mol3d *first_mol); 145 | 146 | int 147 | mol3d_count_atoms (mol3d *mol); 148 | 149 | int 150 | mol3d_count_atoms_all (mol3d *first_mol); 151 | 152 | int 153 | res3d_count_atoms (res3d *res); 154 | 155 | mol3d * 156 | mol3d_lookup (mol3d *first_mol, const char *name); 157 | 158 | res3d * 159 | res3d_lookup (mol3d *mol, const char *name); 160 | 161 | at3d * 162 | at3d_lookup (res3d *res, const char *name); 163 | 164 | res3d * 165 | res3d_find_ordinal (mol3d *mol, int ordinal); 166 | 167 | at3d * 168 | at3d_find_ordinal (mol3d *mol, int ordinal); 169 | 170 | void 171 | mol3d_do_residues (mol3d *mol, void (*proc) (res3d *res)); 172 | 173 | void 174 | mol3d_do_residues_all (mol3d *first_mol, void (*proc) (res3d *res)); 175 | 176 | void 177 | mol3d_do_atoms (mol3d *mol, void (*proc) (at3d *at)); 178 | 179 | void 180 | mol3d_do_atoms_all (mol3d *first_mol, void (*proc) (at3d *at)); 181 | 182 | #endif 183 | -------------------------------------------------------------------------------- /examples/ras_gdp.in: -------------------------------------------------------------------------------- 1 | ! MolScript v2.1 input file 2 | ! generated by MolAuto v1.1 3 | ! modified by hand 4 | 5 | ! View of some residues interacting with GDP. 6 | 7 | title "c-H-ras p21 protein (1-166), complex with GDP and Mg" 8 | 9 | plot 10 | 11 | window 20; 12 | shadows on; 13 | 14 | read mol "ras.pdb"; 15 | 16 | transform atom * 17 | by centre position in residue 200 18 | by rotation 19 | -0.651934 -0.493047 0.576096 20 | 0.669564 -0.017716 0.742543 21 | -0.355903 0.869822 0.341676 22 | by rotation 23 | 0.971127 -0.110519 0.211418 24 | 0.144562 0.977597 -0.152988 25 | -0.189774 0.179134 0.965348 26 | by translation -0.8 0 0 27 | ; 28 | 29 | set planecolour hsb 0.6667 1 1; 30 | coil from 1 to 2; 31 | set planecolour hsb 0.6316 1 1; 32 | strand from 2 to 9; 33 | set planecolour hsb 0.5965 1 1; 34 | coil from 9 to 12; 35 | set planecolour hsb 0.5614 1 1; 36 | cylinder from 17 to 25; 37 | set planecolour hsb 0.5263 1 1; 38 | coil from 25 to 28; 39 | coil from 28 to 38; 40 | set planecolour hsb 0.4912 1 0.4; 41 | strand from 38 to 46; 42 | set planecolour hsb 0.4561 1 1; 43 | coil from 46 to 49; 44 | set planecolour hsb 0.4211 1 1; 45 | strand from 49 to 57; 46 | set planecolour hsb 0.386 1 1; 47 | coil from 57 to 66; 48 | set planecolour hsb 0.3509 1 1; 49 | cylinder from 66 to 75; 50 | set planecolour hsb 0.3158 1 1; 51 | coil from 75 to 77; 52 | set planecolour hsb 0.2807 1 1; 53 | strand from 77 to 84; 54 | set planecolour hsb 0.2456 1 1; 55 | coil from 84 to 87; 56 | set planecolour hsb 0.2105 1 1; 57 | cylinder from 87 to 104; 58 | set planecolour hsb 0.1754 1 1; 59 | coil from 104 to 110; 60 | set planecolour hsb 0.1404 1 1; 61 | strand from 110 to 117; 62 | set planecolour hsb 0.1053 1 1; 63 | coil from 117 to 119; 64 | coil from 119 to 127; 65 | set planecolour hsb 0.07018 1 1; 66 | cylinder from 127 to 138; 67 | set planecolour hsb 0.03509 1 1; 68 | coil from 138 to 145; 69 | coil from 146 to 152; 70 | set planecolour hsb 0 1 1; 71 | cylinder from 152 to 166; 72 | 73 | macro binders 74 | either 75 | in residue 17 76 | , require in residue 146 and either atom N or atom CA 77 | , require in residue 145 and either atom C, atom O or atom CA 78 | or 79 | require backbone 80 | and in from 12 to 16 81 | end_macro; 82 | 83 | set planecolour darkolivegreen; 84 | ball-and-stick require not peptide and in residue 28; 85 | ball-and-stick require not peptide and in residue 117; 86 | ball-and-stick require not peptide and in residue 119; 87 | ball-and-stick $binders; 88 | 89 | set planecolour white; 90 | ball-and-stick in residue 200; 91 | ball-and-stick in residue 201; 92 | 93 | set linecolour orange; 94 | set labeloffset 1 0 0; label res-atom 28 CZ "%r %t"; 95 | set labeloffset -1 -1 0; label res-atom 119 OD1 "%r %t"; 96 | set labeloffset 1 -1 0; label res-atom 117 CE "%r %t"; 97 | set labeloffset 0 -0.7 1; label res-atom 146 N "%r %t"; 98 | set labeloffset -0.5 0.7 0; label res-atom 201 MG "%t"; 99 | set labeloffset -0.5 -1.5 0; label res-atom 13 N "%r %t"; 100 | set labeloffset 0.7 0.5 0; label res-atom 15 N "%r %t"; 101 | set labeloffset -1 1 0; label res-atom 17 CB "%r %t"; 102 | 103 | set linecolour cyan, linedash 4; 104 | line position res-atom 28 CZ 105 | to position require in residue 200 and either atom C6 or atom N3; 106 | line position res-atom 117 CG 107 | to position require in residue 200 and either atom C6 or atom N3; 108 | set linecolour white; 109 | line position res-atom 119 OD2 to position res-atom 200 N2; 110 | line position res-atom 119 OD1 to position res-atom 200 N1; 111 | line position res-atom 146 N to position res-atom 200 O6; 112 | line position res-atom 13 N to position res-atom 200 O3B; 113 | line position res-atom 15 N to position res-atom 200 O2B; 114 | line position res-atom 16 N to position res-atom 200 O2B; 115 | set linecolour orange; 116 | line position res-atom 17 OG to position res-atom 201 MG; 117 | line position res-atom 200 O1B to position res-atom 201 MG; 118 | 119 | viewpoint "GDP molecule" from position require in type GDP and atom N* 120 | to position require in type GDP and atom P* 10; 121 | 122 | viewpoint "Mg ion" from position in require type HOH 123 | and either residue 3 or residue 2 124 | to position in type MG 10; 125 | 126 | viewpoint "far away" origin position in type GDP 100; 127 | 128 | end_plot 129 | -------------------------------------------------------------------------------- /code/eps_img.c: -------------------------------------------------------------------------------- 1 | /* eps_img.c 2 | 3 | MolScript v2.1.2 4 | 5 | Encapsulated PostScript (EPS) image file. 6 | 7 | This implementation relies on the 'image.c' code, and therefore 8 | implicitly on OpenGL and GLX. 9 | 10 | Copyright (C) 1997-1998 Per Kraulis 11 | 13-Sep-1997 working 12 | */ 13 | 14 | #include 15 | #include 16 | 17 | #include 18 | 19 | #include "eps_img.h" 20 | #include "global.h" 21 | #include "graphics.h" 22 | #include "image.h" 23 | #include "opengl.h" 24 | 25 | 26 | /*============================================================*/ 27 | static int components = 3; 28 | static float scale = 1.0; 29 | 30 | 31 | /*------------------------------------------------------------*/ 32 | void 33 | eps_set (void) 34 | { 35 | ogl_set(); 36 | 37 | output_first_plot = eps_first_plot; 38 | output_finish_output = eps_finish_output; 39 | output_start_plot = ogl_start_plot_general; 40 | 41 | output_pickable = NULL; 42 | 43 | output_mode = EPS_MODE; 44 | } 45 | 46 | 47 | /*------------------------------------------------------------*/ 48 | void 49 | eps_first_plot (void) 50 | { 51 | image_first_plot(); 52 | set_outfile ("w"); 53 | 54 | if (fprintf (outfile, "%%!PS-Adobe-3.0 EPSF-3.0\n") < 0) 55 | yyerror ("could not write to the output EPS file"); 56 | 57 | fprintf (outfile, "%%%%BoundingBox: 0 0 %i %i\n", 58 | (int) (scale * output_width + 0.49999), 59 | (int) (scale * output_height + 0.4999)); 60 | if (title) fprintf (outfile, "%%%%Title: %s\n", title); 61 | fprintf (outfile, "%%%%Creator: %s, %s\n", program_str, copyright_str); 62 | if (user_str[0] != '\0') fprintf (outfile, "%%%%For: %s\n", user_str); 63 | PRINT ("%%EndComments\n"); 64 | PRINT ("%%BeginProlog\n"); 65 | PRINT ("10 dict begin\n"); 66 | PRINT ("/bwproc {\n"); 67 | PRINT (" rgbproc\n"); 68 | PRINT (" dup length 3 idiv string 0 3 0\n"); 69 | PRINT (" 5 -1 roll {\n"); 70 | PRINT (" add 2 1 roll 1 sub dup 0 eq\n"); 71 | PRINT (" { pop 3 idiv 3 -1 roll dup 4 -1 roll dup\n"); 72 | PRINT (" 3 1 roll 5 -1 roll put 1 add 3 0 }\n"); 73 | PRINT (" { 2 1 roll } ifelse\n"); 74 | PRINT (" } forall\n"); 75 | PRINT (" pop pop pop\n"); 76 | PRINT ("} def\n"); 77 | PRINT ("systemdict /colorimage known not {\n"); 78 | PRINT (" /colorimage {\n"); 79 | PRINT (" pop pop\n"); 80 | PRINT (" /rgbproc exch def\n"); 81 | PRINT (" { bwproc } image\n"); 82 | PRINT (" } def\n"); 83 | PRINT ("} if\n"); 84 | fprintf (outfile, "/picstr %i string def\n", components * output_width); 85 | PRINT ("%%EndProlog\n"); 86 | PRINT ("%%BeginSetup\n"); 87 | PRINT ("gsave\n"); 88 | fprintf (outfile, "%g %g scale\n", 89 | scale * (float) output_width, scale * (float) output_height); 90 | PRINT ("%%EndSetup\n"); 91 | fprintf (outfile, "%i %i 8\n", output_width, output_height); 92 | fprintf (outfile, "[%i 0 0 %i 0 0]\n", output_width, output_height); 93 | PRINT ("{currentfile picstr readhexstring pop}\n"); 94 | fprintf (outfile, "false %i\n", components); 95 | fprintf (outfile, "%%%%BeginData: %i Hex Bytes\n", 96 | 2 * output_width * output_height * components + 11); 97 | PRINT ("colorimage\n"); 98 | } 99 | 100 | 101 | /*------------------------------------------------------------*/ 102 | void 103 | eps_finish_output (void) 104 | { 105 | int byte_count = output_width * components; 106 | int row, pos, slot; 107 | GLenum format; 108 | unsigned char *buffer; 109 | char *pix; 110 | 111 | format = (components == 1) ? GL_LUMINANCE : GL_RGB; 112 | 113 | image_render(); 114 | 115 | buffer = malloc (byte_count * sizeof (unsigned char)); 116 | 117 | for (row = 0; row < output_height; row++) { 118 | glReadPixels (0, row, output_width, 1, format, GL_UNSIGNED_BYTE, buffer); 119 | pos = 0; 120 | pix = (char *) buffer; 121 | for (slot = 0; slot < byte_count; slot++) { 122 | fprintf (outfile, "%02hx", *pix++); 123 | if (++pos >= 32) { 124 | fprintf (outfile, "\n"); 125 | pos = 0; 126 | } 127 | } 128 | if (pos) fprintf (outfile, "\n"); 129 | } 130 | 131 | free (buffer); 132 | 133 | PRINT ("%%EndData\n"); 134 | PRINT ("grestore\n"); 135 | PRINT ("end\n"); 136 | 137 | image_close(); 138 | } 139 | 140 | 141 | /*------------------------------------------------------------*/ 142 | void 143 | eps_set_bw (void) 144 | { 145 | components = 1; 146 | } 147 | 148 | 149 | /*------------------------------------------------------------*/ 150 | void 151 | eps_set_scale (float new) 152 | { 153 | assert (new > 0.0); 154 | 155 | scale = new; 156 | } 157 | -------------------------------------------------------------------------------- /code/gif_img.c: -------------------------------------------------------------------------------- 1 | /* gif_img.c 2 | 3 | MolScript v2.1.2 4 | 5 | GIF image file. 6 | 7 | This implementation uses the gd 1.3 library by Thomas Boutell, 8 | http://www.boutell.com. The source code for this library does *not* 9 | use LZW compression, so there is no conflict with the (infamous) 10 | Unisys patent on the LZW algorithm. This implementation relies on 11 | the 'image.c' code, and therefore implicitly on OpenGL and GLX. 12 | 13 | Copyright (C) 1998 Per Kraulis 14 | 29-Jul-1998 first attempts 15 | */ 16 | 17 | #include 18 | #include 19 | 20 | #include 21 | 22 | #include 23 | 24 | #include "gif_img.h" 25 | #include "global.h" 26 | #include "graphics.h" 27 | #include "image.h" 28 | #include "opengl.h" 29 | 30 | 31 | /*============================================================*/ 32 | static gdImagePtr image; 33 | 34 | 35 | /*------------------------------------------------------------*/ 36 | void 37 | gifi_set (void) 38 | { 39 | ogl_set(); 40 | 41 | output_first_plot = gifi_first_plot; 42 | output_finish_output = gifi_finish_output; 43 | output_start_plot = ogl_start_plot_general; 44 | 45 | output_pickable = NULL; 46 | 47 | output_mode = GIF_MODE; 48 | } 49 | 50 | 51 | /*------------------------------------------------------------*/ 52 | void 53 | gifi_first_plot (void) 54 | { 55 | int r, g, b, slot; 56 | 57 | image_first_plot(); 58 | set_outfile ("wb"); 59 | 60 | image = gdImageCreate (output_width, output_height); 61 | 62 | for (r = 0; r < 6; r++) { 63 | for (g = 0; g < 6; g++) { 64 | for (b = 0; b < 6; b++) { 65 | slot = gdImageColorAllocate (image, 51 * r, 51 * g, 51 * b); 66 | assert (slot >= 0); 67 | } 68 | } 69 | } 70 | } 71 | 72 | 73 | /*------------------------------------------------------------*/ 74 | void 75 | gifi_finish_output (void) 76 | { 77 | int row, col, value, r, g, b, error, right, leftbelow, below; 78 | unsigned char *buffer, *buf; 79 | int *rcurr, *gcurr, *bcurr, *rnext, *gnext, *bnext, *swap; 80 | 81 | image_render(); 82 | 83 | buffer = malloc (output_width * 3 * sizeof (unsigned char)); 84 | rcurr = malloc ((output_width + 1) * sizeof (int)); 85 | gcurr = malloc ((output_width + 1) * sizeof (int)); 86 | bcurr = malloc ((output_width + 1) * sizeof (int)); 87 | rnext = calloc (output_width + 1, sizeof (int)); 88 | gnext = calloc (output_width + 1, sizeof (int)); 89 | bnext = calloc (output_width + 1, sizeof (int)); 90 | 91 | for (row = 0; row < output_height; row++) { 92 | 93 | swap = rnext; rnext = rcurr; rcurr = swap; 94 | swap = gnext; gnext = gcurr; gcurr = swap; 95 | swap = bnext; bnext = bcurr; bcurr = swap; 96 | for (col = 0; col < output_width; col++) { 97 | rnext[col] = 0; 98 | gnext[col] = 0; 99 | bnext[col] = 0; 100 | } 101 | 102 | glReadPixels (0, output_height - row - 1, output_width, 1, 103 | GL_RGB, GL_UNSIGNED_BYTE, buffer); 104 | buf = buffer; 105 | for (col = 0; col < output_width; col++) { 106 | rcurr[col] += *buf++; 107 | gcurr[col] += *buf++; 108 | bcurr[col] += *buf++; 109 | } 110 | 111 | for (col = 0; col < output_width; col++) { /* error diffusion */ 112 | 113 | value = rcurr[col]; 114 | for (r = 0; 51 * (r + 1) - 26 < value; r++); 115 | error = value - r * 51; 116 | right = (7 * error) / 16; 117 | leftbelow = (3 * error) / 16; 118 | below = (5 * error) / 16; 119 | rcurr[col+1] += right; 120 | if (col > 0) rnext[col-1] += leftbelow; 121 | rnext[col] += below; 122 | rnext[col+1] = error - right - leftbelow - below; 123 | 124 | value = gcurr[col]; 125 | for (g = 0; 51 * (g + 1) - 26 < value; g++); 126 | error = value - g * 51; 127 | right = (7 * error) / 16; 128 | leftbelow = (3 * error) / 16; 129 | below = (5 * error) / 16; 130 | gcurr[col+1] += right; 131 | if (col > 0) gnext[col-1] += leftbelow; 132 | gnext[col] += below; 133 | gnext[col+1] = error - right - leftbelow - below; 134 | 135 | value = bcurr[col]; 136 | for (b = 0; 51 * (b + 1) - 26 < value; b++); 137 | error = value - b * 51; 138 | right = (7 * error) / 16; 139 | leftbelow = (3 * error) / 16; 140 | below = (5 * error) / 16; 141 | bcurr[col+1] += right; 142 | if (col > 0) bnext[col-1] += leftbelow; 143 | bnext[col] += below; 144 | bnext[col+1] = error - right - leftbelow - below; 145 | 146 | gdImageSetPixel (image, col, row, ((r * 6) + g) * 6 + b); 147 | } 148 | } 149 | 150 | free (rnext); 151 | free (gnext); 152 | free (bnext); 153 | free (rcurr); 154 | free (gcurr); 155 | free (bcurr); 156 | free (buffer); 157 | 158 | gdImageGif (image, outfile); 159 | gdImageDestroy (image); 160 | 161 | image_close(); 162 | } 163 | -------------------------------------------------------------------------------- /code/xform.c: -------------------------------------------------------------------------------- 1 | /* xform.c 2 | 3 | MolScript v2.1.2 4 | 5 | Coordinate transformation. 6 | 7 | Copyright (C) 1997-1998 Per Kraulis 8 | 6-Apr-1997 split out of coord.c 9 | 23-Jun-1997 added axis rotation 10 | */ 11 | 12 | #include 13 | 14 | #include "clib/angle.h" 15 | #include "clib/matrix3.h" 16 | #include "clib/quaternion.h" 17 | 18 | #include "xform.h" 19 | #include "global.h" 20 | #include "select.h" 21 | 22 | 23 | /*============================================================*/ 24 | double xform[4][4]; 25 | 26 | static double tmp_xform[4][4]; 27 | static double stored_xform[4][4]; 28 | 29 | 30 | /*------------------------------------------------------------*/ 31 | void 32 | xform_init (void) 33 | { 34 | matrix3_initialize (xform); 35 | } 36 | 37 | 38 | /*------------------------------------------------------------*/ 39 | void 40 | xform_init_stored (void) 41 | { 42 | matrix3_initialize (stored_xform); 43 | } 44 | 45 | 46 | /*------------------------------------------------------------*/ 47 | void 48 | xform_store (void) 49 | { 50 | matrix3_copy (stored_xform, xform); 51 | } 52 | 53 | 54 | /*------------------------------------------------------------*/ 55 | void 56 | xform_centre (void) 57 | { 58 | assert (dstack_size == 3); 59 | 60 | matrix3_translation (tmp_xform, - dstack[0], - dstack[1], - dstack[2]); 61 | matrix3_concatenate (xform, tmp_xform); 62 | 63 | clear_dstack(); 64 | } 65 | 66 | 67 | /*------------------------------------------------------------*/ 68 | void 69 | xform_translation (void) 70 | { 71 | assert (dstack_size == 3); 72 | 73 | matrix3_translation (tmp_xform, dstack[0], dstack[1], dstack[2]); 74 | matrix3_concatenate (xform, tmp_xform); 75 | 76 | clear_dstack(); 77 | } 78 | 79 | 80 | /*------------------------------------------------------------*/ 81 | void 82 | xform_rotation_x (void) 83 | { 84 | assert (dstack_size == 1); 85 | 86 | matrix3_x_rotation (tmp_xform, to_radians (dstack[0])); 87 | matrix3_concatenate (xform, tmp_xform); 88 | 89 | clear_dstack(); 90 | } 91 | 92 | 93 | /*------------------------------------------------------------*/ 94 | void 95 | xform_rotation_y (void) 96 | { 97 | assert (dstack_size == 1); 98 | 99 | matrix3_y_rotation (tmp_xform, to_radians (dstack[0])); 100 | matrix3_concatenate (xform, tmp_xform); 101 | 102 | clear_dstack(); 103 | } 104 | 105 | 106 | /*------------------------------------------------------------*/ 107 | void 108 | xform_rotation_z (void) 109 | { 110 | assert (dstack_size == 1); 111 | 112 | matrix3_z_rotation (tmp_xform, to_radians (dstack[0])); 113 | matrix3_concatenate (xform, tmp_xform); 114 | 115 | clear_dstack(); 116 | } 117 | 118 | 119 | /*------------------------------------------------------------*/ 120 | void 121 | xform_rotation_axis (void) 122 | { 123 | vector3 v; 124 | quaternion q; 125 | 126 | assert (dstack_size == 4); 127 | 128 | v3_initialize (&v, dstack[0], dstack[1], dstack[2]); 129 | if (v3_length (&v) <= 1.0e-10) { 130 | yyerror ("invalid rotation axis: zero length"); 131 | return; 132 | } 133 | quat_initialize_v3 (&q, &v, to_radians (dstack[3])); 134 | quat_to_matrix3 (tmp_xform, &q); 135 | matrix3_concatenate (xform, tmp_xform); 136 | 137 | clear_dstack(); 138 | } 139 | 140 | 141 | /*------------------------------------------------------------*/ 142 | void 143 | xform_rotation_matrix (void) 144 | { 145 | assert (dstack_size == 9); 146 | 147 | matrix3_initialize (tmp_xform); 148 | tmp_xform[0][0] = dstack[0]; 149 | tmp_xform[1][0] = dstack[1]; 150 | tmp_xform[2][0] = dstack[2]; 151 | tmp_xform[0][1] = dstack[3]; 152 | tmp_xform[1][1] = dstack[4]; 153 | tmp_xform[2][1] = dstack[5]; 154 | tmp_xform[0][2] = dstack[6]; 155 | tmp_xform[1][2] = dstack[7]; 156 | tmp_xform[2][2] = dstack[8]; 157 | matrix3_concatenate (xform, tmp_xform); 158 | 159 | clear_dstack(); 160 | } 161 | 162 | 163 | /*------------------------------------------------------------*/ 164 | void 165 | xform_recall_matrix (void) 166 | { 167 | matrix3_concatenate (xform, stored_xform); 168 | } 169 | 170 | 171 | /*------------------------------------------------------------*/ 172 | void 173 | xform_atoms (void) 174 | { 175 | mol3d *mol; 176 | res3d *res; 177 | at3d *at; 178 | int *flags; 179 | int count = 0; 180 | named_data *nd; 181 | 182 | assert (count_atom_selections() == 1); 183 | 184 | flags = current_atom_sel->flags; 185 | for (mol = first_molecule; mol; mol = mol->next) { 186 | for (res = mol->first; res; res = res->next) { 187 | for (at = res->first; at; at = at->next) { 188 | if (*flags++) { 189 | matrix3_transform (&(at->xyz), xform); 190 | count++; 191 | } 192 | } 193 | } 194 | } 195 | 196 | pop_atom_selection(); 197 | 198 | if (message_mode) { 199 | int i, j; 200 | fprintf (stderr, "%i atoms selected for transform\n", count); 201 | fprintf (stderr, "rotation matrix applied:\n"); 202 | for (i = 0; i < 3; i++) { 203 | for (j = 0; j < 3; j++) 204 | fprintf (stderr, "%.8f ", xform[j][i]); 205 | fprintf (stderr, "\n"); 206 | } 207 | fprintf (stderr, "translation vector applied:\n"); 208 | for (i = 0; i < 3; i++) 209 | fprintf (stderr, "%.4f ", xform[3][i]); 210 | fprintf (stderr, "\n"); 211 | } 212 | 213 | assert (count_atom_selections() == 0); 214 | } 215 | -------------------------------------------------------------------------------- /code/clib/element_lookup.c: -------------------------------------------------------------------------------- 1 | /* element_lookup.c 2 | 3 | Chemical element symbol lookup. 4 | 5 | clib v1.1 6 | 7 | Copyright (C) 1998 Per Kraulis 8 | 2-Mar-1998 first attempts 9 | 4-Mar-1998 written 10 | */ 11 | 12 | #include "element_lookup.h" 13 | 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | 20 | /*============================================================*/ 21 | typedef struct { 22 | char *symbol; 23 | int number; 24 | } element_node; 25 | 26 | static element_node element_nodes[] = { 27 | {"H", 1}, 28 | {"He", 2}, 29 | {"Li", 3}, 30 | {"Be", 4}, 31 | {"B", 5}, 32 | {"C", 6}, 33 | {"N", 7}, 34 | {"O", 8}, 35 | {"F", 9}, 36 | {"Ne", 10}, 37 | {"Na", 11}, 38 | {"Mg", 12}, 39 | {"Al", 13}, 40 | {"Si", 14}, 41 | {"P", 15}, 42 | {"S", 16}, 43 | {"Cl", 17}, 44 | {"Ar", 18}, 45 | {"K", 19}, 46 | {"Ca", 20}, 47 | {"Sc", 21}, 48 | {"Ti", 22}, 49 | {"V", 23}, 50 | {"Cr", 24}, 51 | {"Mn", 25}, 52 | {"Fe", 26}, 53 | {"Co", 27}, 54 | {"Ni", 28}, 55 | {"Cu", 29}, 56 | {"Zn", 30}, 57 | {"Ga", 31}, 58 | {"Ge", 32}, 59 | {"As", 33}, 60 | {"Se", 34}, 61 | {"Br", 35}, 62 | {"Kr", 36}, 63 | {"Rb", 37}, 64 | {"Sr", 38}, 65 | {"Y", 39}, 66 | {"Zr", 40}, 67 | {"Nb", 41}, 68 | {"Mo", 42}, 69 | {"Tc", 43}, 70 | {"Ru", 44}, 71 | {"Rh", 45}, 72 | {"Pd", 46}, 73 | {"Ag", 47}, 74 | {"Cd", 48}, 75 | {"In", 49}, 76 | {"Sn", 50}, 77 | {"Sb", 51}, 78 | {"Te", 52}, 79 | {"I", 53}, 80 | {"Xe", 54}, 81 | {"Cs", 55}, 82 | {"Ba", 56}, 83 | {"La", 57}, 84 | {"Ce", 58}, 85 | {"Pr", 59}, 86 | {"Nd", 60}, 87 | {"Pm", 61}, 88 | {"Sm", 62}, 89 | {"Eu", 63}, 90 | {"Gd", 64}, 91 | {"Tb", 65}, 92 | {"Dy", 66}, 93 | {"Ho", 67}, 94 | {"Er", 68}, 95 | {"Tm", 69}, 96 | {"Yb", 70}, 97 | {"Lu", 71}, 98 | {"Hf", 72}, 99 | {"Ta", 73}, 100 | {"W", 74}, 101 | {"Re", 75}, 102 | {"Os", 76}, 103 | {"Ir", 77}, 104 | {"Pt", 78}, 105 | {"Au", 79}, 106 | {"Hg", 80}, 107 | {"Tl", 81}, 108 | {"Pb", 82}, 109 | {"Bi", 83}, 110 | {"Po", 84}, 111 | {"At", 85}, 112 | {"Rn", 86}, 113 | {"Fr", 87}, 114 | {"Ra", 88}, 115 | {"Ac", 89}, 116 | {"Th", 90}, 117 | {"Pa", 91}, 118 | {"U", 92}, 119 | {"Np", 93}, 120 | {"Pu", 94}, 121 | {"Am", 95}, 122 | {"Cm", 96}, 123 | {"Bk", 97}, 124 | {"Cf", 98}, 125 | {"Es", 99}, 126 | {"Fm", 100}, 127 | {"Md", 101}, 128 | {"No", 102}, 129 | {"Lr", 103}, 130 | {"Db", 104}, 131 | {"Jl", 105}, 132 | {"Rf", 106}, 133 | {"Bh", 107}, 134 | {"Hn", 108}, 135 | {"Mt", 109}, 136 | {"Xa", 110}, 137 | {"Xb", 111} 138 | }; 139 | 140 | const int element_max_number = 111; 141 | 142 | 143 | /*============================================================*/ 144 | static element_node *sorted_element_nodes = NULL; 145 | 146 | 147 | /*------------------------------------------------------------*/ 148 | static int 149 | qsort_compare (const void *es1, const void *es2) 150 | { 151 | return strcmp (((element_node *) es1)->symbol, 152 | ((element_node *) es2)->symbol); 153 | } 154 | 155 | 156 | /*------------------------------------------------------------*/ 157 | static void 158 | initialize (void) 159 | { 160 | sorted_element_nodes = malloc (element_max_number * sizeof (element_node)); 161 | memcpy (sorted_element_nodes, element_nodes, 162 | element_max_number * sizeof (element_node)); 163 | qsort (sorted_element_nodes, element_max_number, 164 | sizeof (element_node), qsort_compare); 165 | } 166 | 167 | 168 | /*------------------------------------------------------------*/ 169 | static int 170 | bsearch_compare (const void *key, const void *datum) 171 | { 172 | return strcmp ((char *) key, ((element_node *) datum)->symbol); 173 | } 174 | 175 | 176 | /*------------------------------------------------------------*/ 177 | int 178 | element_number (const char *symbol) 179 | { 180 | element_node *es; 181 | 182 | assert (symbol); 183 | assert (*symbol); 184 | 185 | if (sorted_element_nodes == NULL) initialize(); 186 | es = bsearch (symbol, sorted_element_nodes, element_max_number, 187 | sizeof (element_node), bsearch_compare); 188 | if (es) { 189 | return es->number; 190 | } else { 191 | return 0; 192 | } 193 | } 194 | 195 | 196 | /*------------------------------------------------------------*/ 197 | int 198 | element_number_convert (const char *symbol) 199 | { 200 | char proper[3]; 201 | char c; 202 | 203 | assert (symbol); 204 | assert (*symbol); 205 | 206 | c = symbol[0]; 207 | if (isalpha (c)) { 208 | proper[0] = toupper (c); 209 | c = symbol[1]; 210 | if (c && isalpha (c)) { 211 | proper[1] = tolower (c); 212 | proper[2] = '\0'; 213 | } else { 214 | proper[1] = '\0'; 215 | } 216 | } else { 217 | c = symbol[1]; 218 | if (c && isalpha (c)) { 219 | proper[0] = c; 220 | proper[1] = '\0'; 221 | } else { 222 | return 0; 223 | } 224 | } 225 | 226 | return element_number (proper); 227 | } 228 | 229 | 230 | /*------------------------------------------------------------*/ 231 | int 232 | element_valid_number (int number) 233 | { 234 | return ((number > 0) && (number <= element_max_number)); 235 | } 236 | 237 | 238 | /*------------------------------------------------------------*/ 239 | char * 240 | element_symbol (int element_number) 241 | { 242 | if (element_valid_number (element_number)) { 243 | return element_nodes[element_number-1].symbol; 244 | } else { 245 | return NULL; 246 | } 247 | } 248 | -------------------------------------------------------------------------------- /code/clib/double_hash.c: -------------------------------------------------------------------------------- 1 | /* double_hash.c 2 | 3 | Hash table for objects using string keys, using the double-hashing 4 | scheme. No removal of single entries can be done in this implementation. 5 | 6 | The key and object pointers are assumed to point to memory shared with 7 | other parts of the calling program. No duplication or cleanup of the 8 | memory for these entities is performed by the procedures in this package, 9 | except by the explicit procedure 'dhash_delete_contents'. 10 | 11 | clib v1.0 12 | 13 | Copyright (C) 1997 Per Kraulis 14 | 27-Aug-1997 first attempts 15 | */ 16 | 17 | #include "double_hash.h" 18 | 19 | #include 20 | #include 21 | 22 | #include 23 | 24 | 25 | #define H2(s) (8 - ((s) % 8)) 26 | 27 | 28 | /*------------------------------------------------------------*/ 29 | dhash_table * 30 | dhash_create (const int max_entries) 31 | { 32 | assert (max_entries > 0); 33 | 34 | return dhash_create_size ((int) (max_entries / 0.666666)); 35 | } 36 | 37 | 38 | /*------------------------------------------------------------*/ 39 | dhash_table * 40 | dhash_create_size (const int size) 41 | { 42 | dhash_table *new; 43 | 44 | assert (size > 0); 45 | 46 | new = malloc (sizeof (dhash_table)); 47 | new->count = 0; 48 | new->size = size; 49 | new->keys = calloc (new->size, sizeof (char *)); 50 | new->objects = calloc (new->size, sizeof (void *)); 51 | new->auto_resize = 0.666666; 52 | 53 | return new; 54 | } 55 | 56 | 57 | /*------------------------------------------------------------*/ 58 | void 59 | dhash_resize (dhash_table *table, const int new) 60 | { 61 | char **keys; 62 | void **objects; 63 | int slot, size; 64 | 65 | assert (table); 66 | assert (new > 0); 67 | assert (new > table->size); 68 | 69 | keys = table->keys; 70 | objects = table->objects; 71 | size = table->size; 72 | 73 | table->count = 0; 74 | table->size = new; 75 | table->keys = calloc (table->size, sizeof (char *)); 76 | table->objects = calloc (table->size, sizeof (void *)); 77 | 78 | for (slot = 0; slot < size; slot++) { 79 | dhash_insert (table, keys[slot], objects[slot]); 80 | } 81 | 82 | free (keys); 83 | free (objects); 84 | 85 | assert (table->size == new); 86 | } 87 | 88 | 89 | /*------------------------------------------------------------*/ 90 | void 91 | dhash_delete (dhash_table *table) 92 | { 93 | assert (table); 94 | 95 | free (table->keys); 96 | free (table->objects); 97 | free (table); 98 | } 99 | 100 | /*------------------------------------------------------------*/ 101 | void 102 | dhash_delete_contents (dhash_table *table) 103 | { 104 | int slot; 105 | 106 | assert (table); 107 | 108 | for (slot = 0; slot < table->size; slot++) { 109 | if (table->keys[slot]) { 110 | free (table->keys[slot]); 111 | free (table->objects[slot]); 112 | } 113 | } 114 | 115 | dhash_delete (table); 116 | } 117 | 118 | 119 | /*------------------------------------------------------------*/ 120 | int 121 | dhash_insert (dhash_table *table, char *key, void *object) 122 | { 123 | int slot, u; 124 | 125 | assert (table); 126 | assert (key); 127 | assert (*key); 128 | assert (object); 129 | assert (table->size - table->count > 0); 130 | 131 | if ((double) table->count / (double) table->size >= table->auto_resize) { 132 | dhash_resize (table, 2 * table->size); 133 | } 134 | 135 | slot = str_hashcode (key, table->size); 136 | u = H2 (slot); 137 | while (table->keys[slot]) { 138 | if (str_eq (key, table->keys[slot])) return FALSE; 139 | slot = (slot + u) % table->size; 140 | } 141 | 142 | table->keys[slot] = key; 143 | table->objects[slot] = object; 144 | table->count++; 145 | 146 | return TRUE; 147 | } 148 | 149 | 150 | /*------------------------------------------------------------*/ 151 | void 152 | dhash_insert_replace (dhash_table *table, char *key, void *object) 153 | { 154 | int slot, u; 155 | 156 | assert (table); 157 | assert (key); 158 | assert (*key); 159 | assert (object); 160 | assert (table->size - table->count > 0); 161 | 162 | if ((double) table->count / (double) table->size >= table->auto_resize) { 163 | dhash_resize (table, 2 * table->size); 164 | } 165 | 166 | slot = str_hashcode (key, table->size); 167 | u = H2 (slot); 168 | while (table->keys[slot]) { 169 | if (str_eq (key, table->keys[slot])) break; 170 | slot = (slot + u) % table->size; 171 | } 172 | 173 | table->keys[slot] = key; 174 | table->objects[slot] = object; 175 | table->count++; 176 | } 177 | 178 | 179 | /*------------------------------------------------------------*/ 180 | int 181 | dhash_slot (const dhash_table *table, const char *key) 182 | { 183 | int slot, u; 184 | 185 | assert (table); 186 | assert (key); 187 | assert (*key); 188 | 189 | for (slot = str_hashcode (key, table->size), u = H2 (slot); 190 | ; 191 | slot = (slot + u) % table->size) { 192 | if (table->keys[slot] == NULL) { 193 | return -1; 194 | } else if (str_eq (key, table->keys[slot])) { 195 | return slot; 196 | } 197 | } 198 | } 199 | 200 | 201 | /*------------------------------------------------------------*/ 202 | void * 203 | dhash_object (const dhash_table *table, const char *key) 204 | { 205 | int slot; 206 | 207 | assert (table); 208 | assert (key); 209 | assert (*key); 210 | 211 | slot = dhash_slot (table, key); 212 | if (slot >= 0) { 213 | return table->objects[slot]; 214 | } else { 215 | return NULL; 216 | } 217 | } 218 | -------------------------------------------------------------------------------- /examples/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile 2 | # 3 | # MolScript v2.1 example images 4 | # 5 | # Per Kraulis 6 | # 24-Jul-1998 first attempts 7 | # 31-Oct-2014 output PNG from Raster3d (render); skip JPEG and RGB 8 | 9 | #------------------------------------------------------------ 10 | MOLSCRIPT = ../molscript 11 | MOLAUTO = ../molauto 12 | 13 | RASTER3D = render 14 | 15 | LARGE = -size 600 600 16 | SMALL = -size 180 180 -accum 4 17 | 18 | DOC = ../doc/images 19 | 20 | #------------------------------------------------------------ 21 | .SUFFIXES: .in .ps .wrl .rgb .eps .sgi .jpg .png .gif 22 | 23 | .in.ps: 24 | $(MOLSCRIPT) -postscript -in $< -out $@ 25 | 26 | .in.wrl: 27 | $(MOLSCRIPT) -vrml -in $< -out $@ 28 | 29 | .in.png: 30 | $(MOLSCRIPT) -raster3d $(LARGE) -in $< | $(RASTER3D) -png $@ 31 | 32 | .in.eps: 33 | $(MOLSCRIPT) -eps $(LARGE) -in $< -out $@ 34 | 35 | .in.sgi: 36 | $(MOLSCRIPT) -sgi $(LARGE) -in $< -out $@ 37 | 38 | .in.jpg: 39 | $(MOLSCRIPT) -jpeg $(LARGE) -in $< -out $@ 40 | 41 | .in.gif: 42 | $(MOLSCRIPT) -gif $(LARGE) -in $< -out $@ 43 | 44 | #------------------------------------------------------------ 45 | complete: molauto postscript vrml raster3d eps sgi jpeg png gif 46 | 47 | basic: molauto postscript vrml raster3d 48 | 49 | clean: 50 | rm -f core *~ *.ps *.wrl *.wrl.gz *.sgi *.eps *.rgb *.jpg *.png *.gif 51 | 52 | #------------------------------------------------------------ 53 | molauto: ras_molauto.in ras_molauto_nice.in 54 | 55 | ras_molauto.in: ras.pdb 56 | $(MOLAUTO) $? > $@ 57 | 58 | ras_molauto_nice.in: ras.pdb 59 | $(MOLAUTO) -nice -cpk $? > $@ 60 | 61 | #------------------------------------------------------------ 62 | postscript: ras_std.ps ras_rmsd.ps ras_cyl.ps \ 63 | ras_molauto.ps ras_molauto_nice.ps 64 | 65 | #------------------------------------------------------------ 66 | vrml: ras_std.wrl ras_std_gz.wrl ras_rmsd.wrl ras_shiny.wrl \ 67 | ras_vrml.wrl ras_min_vrml.wrl ras_min_vrml_gz.wrl \ 68 | ras_cyl.wrl ras_cyl_gz.wrl \ 69 | ras_gdp.wrl ras_gdp_gz.wrl \ 70 | ras_molauto.wrl ras_molauto_gz.wrl \ 71 | ras_vrml_lod.wrl ras_vrml_lod_gz.wrl \ 72 | ras_molauto_nice.wrl ras_molauto_nice_gz.wrl 73 | 74 | ras_std_gz.wrl: ras_std.wrl 75 | gzip -c $? > $@ 76 | 77 | ras_min_vrml_gz.wrl: ras_min_vrml.wrl 78 | gzip -c $? > $@ 79 | 80 | ras_cyl_gz.wrl: ras_cyl.wrl 81 | gzip -c $? > $@ 82 | 83 | ras_gdp_gz.wrl: ras_gdp.wrl 84 | gzip -c $? > $@ 85 | 86 | ras_vrml_lod_gz.wrl: ras_vrml_lod.wrl 87 | gzip -c $? > $@ 88 | 89 | ras_molauto_gz.wrl: ras_molauto.wrl 90 | gzip -c $? > $@ 91 | 92 | ras_molauto_nice_gz.wrl: ras_molauto_nice.wrl 93 | gzip -c $? > $@ 94 | 95 | #------------------------------------------------------------ 96 | raster3d: ras_std.png ras_rmsd.png ras_gdp.png 97 | 98 | #------------------------------------------------------------ 99 | eps: ras_std.eps 100 | 101 | #------------------------------------------------------------ 102 | sgi: ras_std.sgi ras_rmsd.sgi ras_shiny.sgi 103 | 104 | #------------------------------------------------------------ 105 | jpeg: ras_std.jpg ras_std_small.jpg \ 106 | ras_rmsd.jpg ras_rmsd_small.jpg \ 107 | ras_shiny.jpg ras_shiny_small.jpg \ 108 | ras_cyl.jpg ras_cyl_small.jpg \ 109 | ras_gdp.jpg ras_gdp_small.jpg \ 110 | ras_molauto.jpg ras_molauto_small.jpg \ 111 | ras_molauto_nice.jpg ras_molauto_nice_small.jpg 112 | 113 | ras_std_small.jpg: ras_std.in 114 | $(MOLSCRIPT) -jpeg $(SMALL) -in ras_std.in -out $@ 115 | 116 | ras_rmsd_small.jpg: ras_rmsd.in 117 | $(MOLSCRIPT) -jpeg $(SMALL) -in $? -out $@ 118 | 119 | ras_shiny_small.jpg: ras_shiny.in 120 | $(MOLSCRIPT) -jpeg $(SMALL) -in $? -out $@ 121 | 122 | ras_cyl_small.jpg: ras_cyl.in 123 | $(MOLSCRIPT) -jpeg $(SMALL) -in $? -out $@ 124 | 125 | ras_gdp_small.jpg: ras_gdp.in 126 | $(MOLSCRIPT) -jpeg $(SMALL) -in $? -out $@ 127 | 128 | ras_molauto_small.jpg: ras_molauto.in 129 | $(MOLSCRIPT) -jpeg $(SMALL) -in $? -out $@ 130 | 131 | ras_molauto_nice_small.jpg: ras_molauto_nice.in 132 | $(MOLSCRIPT) -jpeg $(SMALL) -in $? -out $@ 133 | 134 | #------------------------------------------------------------ 135 | png: ras_std.png ras_shiny.png 136 | 137 | #------------------------------------------------------------ 138 | gif: ras_std.gif ras_cyl.gif 139 | 140 | #------------------------------------------------------------ 141 | doc: $(DOC)/ras_std.jpg \ 142 | $(DOC)/ras_rmsd.jpg \ 143 | $(DOC)/ras_shiny.jpg \ 144 | $(DOC)/ras_gdp_balls.jpg \ 145 | $(DOC)/ras_gdp_bonds.jpg \ 146 | $(DOC)/ras_gdp_cpk.jpg \ 147 | $(DOC)/ras_coil.jpg \ 148 | $(DOC)/ras_cyl.jpg \ 149 | $(DOC)/ras_turn.jpg \ 150 | $(DOC)/ras_trace.jpg 151 | 152 | $(DOC)/ras_std.jpg: ras_std.in 153 | $(MOLSCRIPT) -jpeg $(SMALL) -in $? -out $@ 154 | 155 | $(DOC)/ras_rmsd.jpg: ras_rmsd.in 156 | $(MOLSCRIPT) -jpeg $(SMALL) -in $? -out $@ 157 | 158 | $(DOC)/ras_shiny.jpg: ras_shiny.in 159 | $(MOLSCRIPT) -jpeg $(SMALL) -in $? -out $@ 160 | 161 | $(DOC)/ras_gdp_balls.jpg: ras_gdp_balls.in 162 | $(MOLSCRIPT) -jpeg $(SMALL) -in $? -out $@ 163 | 164 | $(DOC)/ras_gdp_bonds.jpg: ras_gdp_bonds.in 165 | $(MOLSCRIPT) -jpeg $(SMALL) -in $? -out $@ 166 | 167 | $(DOC)/ras_gdp_cpk.jpg: ras_gdp_cpk.in 168 | $(MOLSCRIPT) -jpeg $(SMALL) -in $? -out $@ 169 | 170 | $(DOC)/ras_coil.jpg: ras_coil.in 171 | $(MOLSCRIPT) -jpeg $(SMALL) -in $? -out $@ 172 | 173 | $(DOC)/ras_cyl.jpg: ras_cyl.in 174 | $(MOLSCRIPT) -jpeg $(SMALL) -in $? -out $@ 175 | 176 | $(DOC)/ras_turn.jpg: ras_turn.in 177 | $(MOLSCRIPT) -jpeg $(SMALL) -in $? -out $@ 178 | 179 | $(DOC)/ras_trace.jpg: ras_trace.in 180 | $(MOLSCRIPT) -jpeg $(SMALL) -in $? -out $@ 181 | -------------------------------------------------------------------------------- /docs/syntax.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | MolScript v2.1: Syntax summary 4 | 5 | 6 | 7 | 8 | 9 |

Syntax summary

10 | 11 | This is a summary of the MolScript input file syntax. It is a 12 | simplification of the actual yacc grammar (file molscript.y), which 13 | describes the syntax in a condensed form using a Backus-Naur Form 14 | (BNF) notation. Undocumented features are omitted. 15 |

16 | 17 |


18 | 19 |
 20 | input_file: [title string] plot {plot} ;
 21 | 
 22 | plot: {macro_def} plot {header_command} {body_command} end_plot ;
 23 | 
 24 | macro_def: macro macro_id commands end_macro ;
 25 | 
 26 | header_command: < noframe
 27 |                 | frame < on | off > ';'
 28 |                 | area number number number number ';'
 29 |                 | background colour ';'
 30 |                 | window number ';'
 31 |                 | slab number ';'
 32 |                 | headlight < on | off > ';'
 33 |                 | shadows < on | off > ';'
 34 |                 | fog number ';'
 35 |                 >
 36 | 
 37 | body_command: < read mol_id filename ';'
 38 |               | read mol_id inline-PDB ';'
 39 |               | copy mol_id atom_selection ';'
 40 |               | delete mol_id ';'
 41 |               | comment string ';'
 42 |               | debug string ';'
 43 |               | transform atom_selection {by xform} ';'
 44 |               | store-matrix ';'
 45 |               | macro_def ';' >
 46 |               | set parameter_spec {',' parameter_spec} ';'
 47 |               | ball-and-stick atom_selection [atom_selection] ';'
 48 |               | bonds atom_selection [atom_selection] ';'
 49 |               | coil residue_selection ';'
 50 |               | cylinder residue_selection ';'
 51 |               | cpk atom_selection ';'
 52 |               | double-helix residue_selection ';'
 53 |               | helix residue_selection ';'
 54 |               | label vector string ';'
 55 |               | label atom_selection string ';'
 56 |               | line vector to vector {to vector} ';'
 57 |               | object filename ';'
 58 |               | object inline ';'
 59 |               | strand residue_selection ';'
 60 |               | turn residue_selection ';'
 61 |               | viewpoint id origin vector number ';'
 62 |               | directionallight vector ';'
 63 |               | directionallight from vector to vector ';'
 64 |               | pointlight vector ';'
 65 |               | spotlight vector vector number ';'
 66 |               | spotlight from vector to vector number ';'
 67 |               | anchor id [description string] {parameter string}
 68 |                   '{' basic_commands '}' ';'
 69 |               | level-of-detail
 70 |                   { number '{' basic_commands '}' }
 71 |                   '{' basic_commands '}' ';'
 72 |               | viewpoint id from vector to vector [number] ';'
 73 |               >
 74 | 
 75 | atom_selection: < not atom_selection
 76 |                 | require atom_selection {',' atom_selection}
 77 |                     and atom_selection
 78 |                 | either atom_selection {',' atom_selection}
 79 |                     or atom_selection
 80 |                 | atom atom_id
 81 |                 | res-atom residue_name atom_id
 82 |                 | occupancy number number
 83 |                 | b-factor number number
 84 |                 | in residue_selection
 85 |                 | sphere vector number
 86 |                 | close atom_selection number
 87 |                 | peptide
 88 |                 | backbone
 89 |                 | hydrogens
 90 |                 >
 91 | 
 92 | residue_selection: < not residue_selection
 93 |                    | require residue_selection {',' residue_selection}
 94 |                        and residue_selection
 95 |                    | either residue_selection {',' residue_selection}
 96 |                        or residue_selection
 97 |                    | molecule mol_id
 98 |                    | model integer
 99 |                    | from residue_name to residue_name
100 |                    | residue residue_name
101 |                    | type residue_type
102 |                    | chain chain_id
103 |                    | contains atom_selection
104 |                    | amino-acids
105 |                    | waters
106 |                    | nucleotides
107 |                    | ligands
108 |                    | segid segment_id
109 |                    >
110 | 
111 | 112 |
113 | Top page 114 | 115 | 116 | -------------------------------------------------------------------------------- /code/Makefile.complete: -------------------------------------------------------------------------------- 1 | # Makefile 2 | # 3 | # MolScript v2.1.2, the complete implementation: all output modes enabled. 4 | # 5 | # If your computer system lacks one or more of the required libraries, 6 | # then you will have to comment out the relevant symbol definitions 7 | # below. If none of them are installed, use Makefile.basic instead. 8 | # For more information, see the 'doc/installation.html' file. 9 | # 10 | # Per Kraulis 11 | # 1-Dec-1996 first attempts 12 | # 13-Sep-1997 rearranged optional implementations 13 | # 22-Oct-1997 modified for distribution 14 | # 19-Nov-1997 checked for distribution 15 | # 15-Aug-1998 reorganized for v2.1 16 | # 1-Nov-2014 rearranged directories for GitHub 17 | 18 | # Executables 19 | MOLSCRIPT = ../molscript 20 | MOLAUTO = ../molauto 21 | 22 | # Command execution shell. 23 | SHELL = /bin/sh 24 | 25 | # Global external software directory. 26 | # If not set in your .cshrc, then set it here. <--- 27 | #FREEWAREDIR = /usr/local 28 | 29 | # OpenGL and GLUT for X (UNIX). 30 | # Must be modified for Windows 95/NT. <--- 31 | GLUTDIR = $(FREEWAREDIR)/glut 32 | GLUTLINK = $(GLUTDIR)/lib/glut/libglut.a -lGLU -lGL -lXmu -lXext -lX11 33 | OPENGLFLAG = -DOPENGL_SUPPORT -I$(GLUTDIR)/include 34 | OPENGLOBJ = opengl.o 35 | OPENGLCLIBOBJ = ogl_utils.o ogl_body.o ogl_bitmap_character.o 36 | 37 | # Image file formats which require only OpenGL, GLUT and X (UNIX). 38 | IMAGEFLAG = -DIMAGE_SUPPORT 39 | IMAGEOBJ = image.o eps_img.o sgi_img.o 40 | 41 | # JPEG image file format; requires the JPEG library. 42 | # Comment out these lines if the JPEG library is not available. <--- 43 | JPEGDIR = $(FREEWAREDIR)/jpeg 44 | JPEGLINK = $(JPEGDIR)/libjpeg.a 45 | JPEGFLAG = -DJPEG_SUPPORT -I$(JPEGDIR) 46 | JPEGOBJ = jpeg_img.o 47 | 48 | # PNG image file format; requires the PNG library and the zlib library. 49 | # Comment out these lines if the PNG and zlib libraries are not available. <--- 50 | ZLIBDIR = $(FREEWAREDIR)/zlib 51 | ZLIBLINK = $(ZLIBDIR)/libz.a 52 | PNGDIR = $(FREEWAREDIR)/libpng 53 | PNGLINK = $(PNGDIR)/libpng.a 54 | PNGFLAG = -DPNG_SUPPORT -I$(PNGDIR) -I$(ZLIBDIR) 55 | PNGOBJ = png_img.o 56 | 57 | # GIF image file format; requires the gd 1.3 library. 58 | # Comment out these lines if the gd 1.3 library is not available. <--- 59 | GIFDIR = $(FREEWAREDIR)/gd 60 | GIFLINK = $(GIFDIR)/libgd.a 61 | GIFFLAG = -DGIF_SUPPORT -I$(GIFDIR) 62 | GIFOBJ = gif_img.o 63 | 64 | # SGI IRIX's C compiler. 65 | CC = cc -32 66 | # Optimization flags: 67 | COPT = -O1 68 | # Correctness flags: 69 | #CCHECK = -ansi -fullwarn -g -DSELECT_DEBUG 70 | CCHECK = -ansi -fullwarn 71 | #CCHECK = -ansi -fullwarn -DNDEBUG 72 | 73 | # General cc compile flags. 74 | CFLAGS = $(COPT) $(CCHECK) -Iclib $(OPENGLFLAG) $(IMAGEFLAG) $(JPEGFLAG) \ 75 | $(PNGFLAG) $(GIFFLAG) 76 | 77 | # GNU's bison; required instead of the ordinary yacc. 78 | YACC = bison 79 | YFLAGS = -d 80 | YLIB = 81 | 82 | #------------------------------------------------------------ 83 | OBJ = molscript.tab.o global.o lex.o col.o select.o \ 84 | state.o graphics.o segment.o coord.o xform.o \ 85 | postscript.o raster3d.o vrml.o regex.o \ 86 | $(OPENGLOBJ) $(IMAGEOBJ) $(JPEGOBJ) $(PNGOBJ) $(GIFOBJ) 87 | 88 | #------------------------------------------------------------ 89 | all: $(MOLSCRIPT) $(MOLAUTO) 90 | 91 | #------------------------------------------------------------ 92 | clean: 93 | (rm -f $(MOLSCRIPT) $(MOLAUTO) *.o core *~) 94 | (cd clib; make clean) 95 | 96 | #------------------------------------------------------------ 97 | $(MOLSCRIPT): $(OBJ) clib/clib.a 98 | $(CC) -o $(MOLSCRIPT) $(COPT) $(OBJ) $(YLIB) clib/clib.a \ 99 | $(GLUTLINK) $(JPEGLINK) $(PNGLINK) $(GIFLINK) $(ZLIBLINK) -lm 100 | 101 | molscript.tab.o: molscript.tab.c molscript.tab.h 102 | 103 | molscript.tab.c molscript.tab.h: molscript.y 104 | $(YACC) $(YFLAGS) molscript.y 105 | 106 | global.o: global.c global.h lex.h state.h graphics.h xform.h \ 107 | postscript.h raster3d.h vrml.h 108 | 109 | lex.o: lex.c lex.h global.h molscript.tab.h 110 | 111 | col.o: col.c col.h global.h lex.h state.h 112 | 113 | select.o: select.c select.h coord.h global.h state.h lex.h 114 | 115 | state.o: state.c state.h col.h global.h select.h 116 | 117 | graphics.o: graphics.c graphics.h coord.h state.h global.h lex.h \ 118 | select.h xform.h segment.h postscript.h raster3d.h vrml.h 119 | 120 | segment.o: segment.c segment.h 121 | 122 | coord.o: coord.c coord.h global.h lex.h select.h 123 | 124 | xform.o: xform.c xform.h global.h select.h 125 | 126 | postscript.o: postscript.c postscript.h coord.h global.h \ 127 | graphics.h segment.h state.h 128 | 129 | raster3d.o: raster3d.c raster3d.h coord.h global.h graphics.h \ 130 | segment.h state.h 131 | 132 | vrml.o: vrml.c vrml.h col.h coord.h global.h graphics.h segment.h state.h 133 | 134 | regex.o: other/regex.c 135 | $(CC) $(CFLAGS) -c -o ./regex.o other/regex.c 136 | 137 | opengl.o: opengl.c opengl.h col.h coord.h global.h graphics.h \ 138 | segment.h state.h lex.h select.h 139 | 140 | image.o: image.c image.h global.h graphics.h opengl.h 141 | 142 | eps_img.o: eps_img.c eps_img.h global.h graphics.h opengl.h 143 | 144 | sgi_img.o: sgi_img.c sgi_img.h global.h graphics.h image.h opengl.h 145 | 146 | jpeg_img.o: jpeg_img.c jpeg_img.h global.h graphics.h image.h opengl.h 147 | 148 | png_img.o: png_img.c png_img.h global.h graphics.h image.h opengl.h 149 | 150 | gif_img.o: gif_img.c gif_img.h global.h graphics.h image.h opengl.h 151 | 152 | #------------------------------------------------------------ 153 | $(MOLAUTO): molauto.o clib/clib.a 154 | $(CC) -o $(MOLAUTO) molauto.o clib/clib.a -lm 155 | 156 | molauto.o: molauto.c 157 | 158 | #------------------------------------------------------------ 159 | clib/clib.a: 160 | cd clib; make clib.a CFLAGS="-I. $(CFLAGS)" OPENGLCLIBOBJ="$(OPENGLCLIBOBJ)" 161 | -------------------------------------------------------------------------------- /code/clib/extent3d.c: -------------------------------------------------------------------------------- 1 | /* 2 | 3D extent stack routines. 3 | 4 | clib v1.1 5 | 6 | Copyright (C) 1997-1998 Per Kraulis 7 | 8-Mar-1997 started writing 8 | 23-Aug-1997 fixed bugs: size in extent3d_set and ext_count in extent3d_pop 9 | 24-Jun-1998 mod's for hgen, added get/set_low_high, renamed 10 | */ 11 | 12 | #include "extent3d.h" 13 | 14 | /* public ==================== 15 | #include 16 | #include 17 | ==================== public */ 18 | 19 | #include 20 | #include 21 | 22 | 23 | /*============================================================*/ 24 | typedef struct { 25 | double xlo, xhi, ylo, yhi, zlo, zhi; 26 | } extent3d; 27 | 28 | 29 | static extent3d *ext_array = NULL; 30 | static extent3d *curr_ext = NULL; 31 | static int ext_alloc = 8; 32 | static int ext_count = 0; 33 | 34 | 35 | /*------------------------------------------------------------*/ 36 | void 37 | ext3d_initialize (void) 38 | { 39 | if (ext_array == NULL) { 40 | ext_array = malloc (ext_alloc * sizeof (extent3d)); 41 | ext_count = 1; 42 | } 43 | 44 | curr_ext = ext_array + ext_count - 1; 45 | 46 | curr_ext->xlo = 1.0e20; 47 | curr_ext->xhi = -1.0e20; 48 | curr_ext->ylo = 1.0e20; 49 | curr_ext->yhi = -1.0e20; 50 | curr_ext->zlo = 1.0e20; 51 | curr_ext->zhi = -1.0e20; 52 | 53 | assert (ext_count >= 1); 54 | assert (curr_ext); 55 | } 56 | 57 | 58 | /*------------------------------------------------------------*/ 59 | void 60 | ext3d_push (void) 61 | { 62 | extent3d *ext; 63 | #ifndef NDEBUG 64 | int old_count = ext_count; 65 | #endif 66 | 67 | assert (curr_ext); 68 | 69 | if (ext_count >= ext_alloc) { 70 | ext_alloc *= 2; 71 | ext_array = realloc (ext_array, ext_alloc * sizeof (extent3d)); 72 | } 73 | 74 | ext = ext_array + ext_count - 1; 75 | ext_count++; 76 | curr_ext = ext_array + ext_count - 1; 77 | *curr_ext = *ext; 78 | 79 | #ifndef NDEBUG 80 | assert (ext_count == old_count + 1); 81 | #endif 82 | } 83 | 84 | 85 | /*------------------------------------------------------------*/ 86 | void 87 | ext3d_pop (boolean transfer) 88 | { 89 | extent3d *ext = curr_ext; 90 | #ifndef NDEBUG 91 | int old_count = ext_count; 92 | #endif 93 | 94 | assert (curr_ext); 95 | assert (ext_count > 1); 96 | 97 | ext_count--; 98 | curr_ext = ext_array + ext_count - 1; 99 | 100 | if (transfer) { 101 | if (curr_ext->xlo > ext->xlo) curr_ext->xlo = ext->xlo; 102 | if (curr_ext->xhi < ext->xhi) curr_ext->xhi = ext->xhi; 103 | if (curr_ext->ylo > ext->ylo) curr_ext->ylo = ext->ylo; 104 | if (curr_ext->yhi < ext->yhi) curr_ext->yhi = ext->yhi; 105 | if (curr_ext->zlo > ext->zlo) curr_ext->zlo = ext->zlo; 106 | if (curr_ext->zhi < ext->zhi) curr_ext->zhi = ext->zhi; 107 | } 108 | 109 | #ifndef NDEBUG 110 | assert (ext_count == old_count - 1); 111 | #endif 112 | } 113 | 114 | 115 | /*------------------------------------------------------------*/ 116 | int 117 | ext3d_depth (void) 118 | { 119 | return ext_count; 120 | } 121 | 122 | 123 | /*------------------------------------------------------------*/ 124 | void 125 | ext3d_get_center_size (vector3 *center, vector3 *size) 126 | { 127 | assert (center); 128 | assert (size); 129 | assert (curr_ext); 130 | assert (ext_count >= 1); 131 | 132 | center->x = 0.5 * (curr_ext->xlo + curr_ext->xhi); 133 | center->y = 0.5 * (curr_ext->ylo + curr_ext->yhi); 134 | center->z = 0.5 * (curr_ext->zlo + curr_ext->zhi); 135 | size->x = curr_ext->xhi - curr_ext->xlo; 136 | size->y = curr_ext->yhi - curr_ext->ylo; 137 | size->z = curr_ext->zhi - curr_ext->zlo; 138 | } 139 | 140 | 141 | /*------------------------------------------------------------*/ 142 | void 143 | ext3d_get_low_high (vector3 *low, vector3 *high) 144 | { 145 | assert (low); 146 | assert (high); 147 | assert (curr_ext); 148 | assert (ext_count >= 1); 149 | 150 | low->x = curr_ext->xlo; 151 | low->y = curr_ext->ylo; 152 | low->z = curr_ext->zlo; 153 | high->x = curr_ext->xhi; 154 | high->y = curr_ext->yhi; 155 | high->z = curr_ext->zhi; 156 | } 157 | 158 | 159 | /*------------------------------------------------------------*/ 160 | void 161 | ext3d_set_center_size (vector3 *center, vector3 *size) 162 | { 163 | assert (center); 164 | assert (size); 165 | assert (curr_ext); 166 | assert (ext_count >= 1); 167 | 168 | curr_ext->xlo = center->x - 0.5 * size->x; 169 | curr_ext->xhi = center->x + 0.5 * size->x; 170 | curr_ext->ylo = center->y - 0.5 * size->y; 171 | curr_ext->yhi = center->y + 0.5 * size->y; 172 | curr_ext->zlo = center->z - 0.5 * size->z; 173 | curr_ext->zhi = center->z + 0.5 * size->z; 174 | } 175 | 176 | 177 | /*------------------------------------------------------------*/ 178 | void 179 | ext3d_set_low_high (vector3 *low, vector3 *high) 180 | { 181 | assert (low); 182 | assert (high); 183 | assert (curr_ext); 184 | assert (ext_count >= 1); 185 | 186 | curr_ext->xlo = low->x; 187 | curr_ext->xhi = low->y; 188 | curr_ext->ylo = low->z; 189 | curr_ext->yhi = high->x; 190 | curr_ext->zlo = high->y; 191 | curr_ext->zhi = high->z; 192 | } 193 | 194 | 195 | /*------------------------------------------------------------*/ 196 | void 197 | ext3d_update (vector3 *p, double radius) 198 | { 199 | register double u; 200 | 201 | assert (p); 202 | assert (radius >= 0.0); 203 | assert (radius < 1.0e20); 204 | assert (curr_ext); 205 | assert (ext_count >= 1); 206 | 207 | u = p->x - radius; 208 | if (u < curr_ext->xlo) curr_ext->xlo = u; 209 | u = p->x + radius; 210 | if (u > curr_ext->xhi) curr_ext->xhi = u; 211 | u = p->y - radius; 212 | if (u < curr_ext->ylo) curr_ext->ylo = u; 213 | u = p->y + radius; 214 | if (u > curr_ext->yhi) curr_ext->yhi = u; 215 | u = p->z - radius; 216 | if (u < curr_ext->zlo) curr_ext->zlo = u; 217 | u = p->z + radius; 218 | if (u > curr_ext->zhi) curr_ext->zhi = u; 219 | } 220 | --------------------------------------------------------------------------------