@@ -3503,49 +3503,19 @@ out, including on a non-local exit."
35033503 (need cc))))))
35043504 table))
35053505
3506- (defun train-foldamer-contexts (foldamer contexts &key verbose)
3507- " Train FOLDAMER's parameter cache on CONTEXTS. Returns (values TRAINED MISSING), or
3506+
3507+ (defgeneric train-foldamer-contexts (foldamer contexts &key verbose)
3508+ (:documentation
3509+ " Train FOLDAMER's parameter cache on CONTEXTS. Returns (values TRAINED MISSING), or
35083510(values 0 NIL) when this foldamer has no cache to train.
35093511
35103512 A foldamer whose force field is not a CACHED-SMIRNOFF-FORCE-FIELD is skipped, not an error:
35113513 AMBER types from residue templates, so there is nothing a trainer could contribute.
35123514
35133515 The name need not be a registered force field at all - AMBER-PROTEIN's is the cons
35143516 (:DEFAULT . :USE-GIVEN-TYPES), and CHEM:FIND-FORCE-FIELD SIGNALS on an unknown name rather than
3515- returning NIL. An unregistered name is just a louder way of saying there is no cache here."
3516- (let* ((force-field-name (oligomer-force-field-name foldamer))
3517- (ff (handler-case (chem :find-force-field force-field-name)
3518- (error () nil ))))
3519- (unless (typep ff ' smirnoff:cached-smirnoff-force-field)
3520- (when verbose
3521- (format t " ~& ~a (~s ): ~a - ~d context~:p need no training~% "
3522- (type-of foldamer) force-field-name
3523- (if ff " no parameter cache" " no registered force field" )
3524- (length contexts)))
3525- (return-from train-foldamer-contexts (values 0 nil )))
3526- (let ((cache (smirnoff :cache ff))
3527- (index (foldamer-trainer-index foldamer))
3528- (trained 0 )
3529- (missing nil ))
3530- (dolist (cc contexts)
3531- ; ; Re-read coverage every round: a trainer stores keys for EVERY atom in it, not just its
3532- ; ; focus, so building one context routinely covers neighbours for free.
3533- (unless (gethash cc (cache-trained-contexts cache))
3534- (let ((entry (gethash cc index)))
3535- (cond (entry
3536- (when verbose
3537- (format t " ~& training ~s~% " cc)
3538- (finish-output ))
3539- ; ; The build IS the training: the trainer's molecule uses this same registered
3540- ; ; force field, so it misses, runs real SMIRNOFF on chemically real geometry,
3541- ; ; and HARVEST-INTO-CACHE files the result. The assembler is discarded.
3542- (make-training-assembler (list (car entry)) :focus-monomer (cdr entry))
3543- (incf trained))
3544- (t (push cc missing))))))
3545- ; ; A context with no trainer of its own may still have been covered incidentally.
3546- (let ((have (cache-trained-contexts cache)))
3547- (setf missing (remove-if (lambda (cc) (gethash cc have)) missing)))
3548- (values trained missing))))
3517+ returning NIL. An unregistered name is just a louder way of saying there is no cache here." ))
3518+
35493519
35503520(defun blueprint-required-constitution-contexts (blueprint)
35513521 " Every constitution-context this BLUEPRINT will stamp as :GIVEN-ATOM-TYPE, pooled across
@@ -3574,18 +3544,6 @@ BLUEPRINT-REQUIRED-CONTEXTS-BY-FOLDAMER.
35743544 (when cc (pushnew cc contexts :test #' equal ))))))
35753545 (nreverse contexts)))
35763546
3577- (defun cache-trained-contexts (cache)
3578- " The set of constitution-contexts CACHE already holds parameters for, as an EQUAL hash-table.
3579-
3580- Read off NONBOND-TABLE rather than the bonded tables: it has one entry per typed atom keyed by a
3581- single (atom-name . constitution-context) cons, so every trained context appears in it, whereas a
3582- bonded key is a list of parts."
3583- (let ((set (make-hash-table :test ' equal)))
3584- (maphash (lambda (key parameters)
3585- (declare (ignore parameters))
3586- (setf (gethash (cdr key) set ) t ))
3587- (smirnoff :nonbond-table cache))
3588- set ))
35893547
35903548(defgeneric foldamer-trainer-index (foldamer)
35913549 (:documentation " CONSTITUTION-CONTEXT -> (OLIGOMER . FOCUS-MONOMER) for every trainer FOLDAMER can build.
0 commit comments