Save-partial.scm

From CCP4 wiki
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

(define (save-partial imol atom-selection filename)

  (if (valid-model-molecule? imol)
      (begin
	(let ((imol-new 
	       (new-molecule-by-atom-selection imol atom-selection)))
	  (if (not (valid-model-molecule? imol-new))
	      (let ((s "That atom selection did not create a valid molecule"))
		(add-status-bar-text s))
	      (let ((s (string-append "Saved partial model to "
				       filename)))
		 (write-pdb-file imol-new filename)
		 (add-status-bar-text s)
		 (close-molecule imol-new)))))))
	       

(let ((menu (coot-menubar-menu "Extensions")))

  (add-simple-coot-menu-menuitem
   menu "Save Partial Model..."
   (lambda () 

     (molecule-chooser-gui 
      "Save a selection from molecule: "
      (lambda (imol) 
	(let ((cv (coot-version)))
	  (if (string<? cv "0.3.3")
	      (generic-double-entry "Atom Selection: " "Coordinates Filename: "
				    "//A/1-10" "save.pdb" " Save Partial Model "
				    (lambda (atom-selection-str pdb-name)
				      (save-partial imol atom-selection-str pdb-name)))
	      (generic-double-entry "Atom Selection: " "Coordinates Filename: "
				    "//A/1-10" "save.pdb" #f #f " Save Partial Model "
				    (lambda (atom-selection-str pdb-name button-state)
				      (save-partial imol atom-selection-str pdb-name))))))))))