/** * Documentation for this function. */ function onMakeFinalPDB() { $context = getContext(); $newModel = $_SESSION['models'][$context['newModel']]; $oldModel = $_SESSION['models'][$newModel['parent']]; $newPDB = $_SESSION['dataDir'] . '/' . MP_DIR_MODELS . '/' . $newModel['pdb']; $oldPDB = $_SESSION['dataDir'] . '/' . MP_DIR_MODELS . '/' . $oldModel['pdb']; $url = $_SESSION['dataURL'] . '/' . MP_DIR_MODELS . '/' . $newModel['pdb']; // Put our money where our mouth is and calculate that new PDB file $all_changes = $context['sswingChanges']; $usercnit = $_REQUEST['cnit']; // Remove changes for residues that weren't selected foreach ($all_changes as $k => $v) { $res = substr($k, 0, 9); if (!isset($usercnit[$res])) { unset($all_changes[$k]); } else { $changed_res[$res] = $res; } // used below for the lab notebook } // Make PDB file pdbSwapCoords($oldPDB, $newPDB, $all_changes); // Make up the lab notebook entry $text = "The following residues were automatically refit by SSWING, creating {$newModel['pdb']} from {$oldModel['pdb']}:\n<ul>\n"; foreach ($changed_res as $res) { $text .= "<li>{$res}</li>\n"; } $text .= "</ul>\n"; $text .= "<p>You can now <a href='{$url}'>download the optimized and annotated PDB file</a> (" . formatFilesize(filesize($newPDB)) . ").</p>\n"; $entryNum = addLabbookEntry("Refit sidechains with SSWING to get {$newModel['pdb']}", $text, "{$oldModel['id']}|{$newModel['id']}", 'auto'); $ctx = array('labbookEntry' => $entryNum); pageGoto("generic_done.php", $ctx); }
foreach ($cnit as $res) { $tasks[$res] = "Process {$res} with SSWING"; } $tasks["combine"] = "Combine all changes and create kinemage"; $tmpdir = $_SESSION['dataDir'] . '/' . MP_DIR_WORK; if (!file_exists($tmpdir)) { mkdir($tmpdir, 0777); } $all_changes = array(); foreach ($cnit as $res) { setProgress($tasks, $res); $changes = runSswing($pdbin, $map, $tmpdir, $res, $_SESSION['bgjob']['fastSearch'] ? true : false); $all_changes = array_merge($all_changes, $changes); } setProgress($tasks, "combine"); pdbSwapCoords($pdbin, $pdbout, $all_changes); $kindir = $_SESSION['dataDir'] . '/' . MP_DIR_KINS; if (!file_exists($kindir)) { mkdir($kindir, 0777); } makeSswingKin($pdbin, $pdbout, "{$kindir}/{$newModel['prefix']}sswing.kin", $cnit); $_SESSION['bgjob']['newModel'] = $newModel['id']; $_SESSION['lastUsedModelID'] = $newModel['id']; // this is now the current model $_SESSION['bgjob']['sswingChanges'] = $all_changes; setProgress($tasks, null); ############################################################################ // Clean up and go home unset($_SESSION['bgjob']['processID']); $_SESSION['bgjob']['endTime'] = time(); $_SESSION['bgjob']['isRunning'] = false;