Пример #1
0
 /**
 * If the user requested to save changes, make sure we do that before returning.
 */
 function onSaveEntry()
 {
     $req = $_REQUEST;
     // Did we get an edit request?
     if ($req['labbookEditCmd'] == "Save") {
         $labbook = openLabbook();
         if (isset($req['entryNumber'])) {
             $entryNum = $req['entryNumber'];
             $labbook[$entryNum] = $req['labbookEntry'];
             mpLog("notebook-edit:User modified existing lab notebook entry");
         } else {
             $entryNum = count($labbook);
             $labbook[$entryNum] = $req['labbookEntry'];
             mpLog("notebook-add:User added a new entry to the lab notebook");
         }
         saveLabbook($labbook);
     }
     pageReturn();
 }
Пример #2
0
 /**
 * Documentation for this function.
 */
 function onStartSSwing()
 {
     $req = $_REQUEST;
     if ($req['cmd'] == 'Go back') {
         $c = getContext();
         $ctx['modelID'] = $c['modelID'];
         $ctx['map'] = $c['map'];
         pageGoto("sswing_setup1.php", $ctx);
         return;
     }
     $ctx = getContext();
     unset($_SESSION['bgjob']);
     // Clean up any old data
     $_SESSION['bgjob']['modelID'] = $ctx['modelID'];
     $_SESSION['bgjob']['edmap'] = $ctx['map'];
     $_SESSION['bgjob']['cnit'] = $req['cnit'];
     $_SESSION['bgjob']['fastSearch'] = $req['fastSearch'];
     mpLog("sswing:Launched SSWING to refit " . count($_req['cnit']) . " residue(s)");
     // launch background job
     pageGoto("job_progress.php");
     launchBackground(MP_BASE_DIR . "/jobs/sswing.php", "sswing_choose.php", 5);
 }
Пример #3
0
 /**
 * Launches Prekin when the user submits the form.
 */
 function onRunProbe()
 {
     $req = $_REQUEST;
     //if($req['cmd'] == 'Cancel')
     if ($req['cmd'] == 'Go back') {
         pageGoto("interface_setup1.php");
         return;
     }
     // Otherwise, moving forward:
     $_SESSION['lastUsedModelID'] = $req['modelID'];
     // this is now the current model
     unset($_SESSION['bgjob']);
     // Clean up any old data
     $_SESSION['bgjob'] = $req;
     mpLog("interface:Visualizing interface contacts with complex Probe run");
     // launch background job
     pageGoto("job_progress.php");
     launchBackground(MP_BASE_DIR . "/jobs/interface-vis.php", "generic_done.php", 5);
 }
Пример #4
0
 /**
 * This function calls the notebook editor so the user can modify the notebook
 * entry. Control is transfered to another page, namely, notebook_edit.php.
 * When that page is done, it will call pageReturn(), and control will return
 * to this class--display() will be called again to show the entry.
 *
 * This function gets called when the user clicks the link made by display()
 *
 * $arg contains the entry number of the notebook entry to edit. It was specified
 * by the call to makeEventURL() that occurs in display(), above.
 * $req is filled in with the usually info from the form submission, but
 * we don't need to use it for anything here.
 */
 function onPdbConvert()
 {
     $req = $_REQUEST;
     if ($req['cmd'] == 'Cancel') {
         pageReturn();
         return;
     }
     if (isset($req['modelID'])) {
         $_SESSION['lastUsedModelID'] = $req['modelID'];
         // this is now the current model
         unset($_SESSION['bgjob']);
         // Clean up any old data
         $_SESSION['bgjob'] = $req;
         mpLog("convertPdb:Converted '{$req['modelID']}' to PDBv2.3");
         // launch background job
         pageGoto("job_progress.php");
         launchBackground(MP_BASE_DIR . "/jobs/pdb_convert.php", "generic_done.php", 3);
     } else {
         $context = getContext();
         if (isset($req['modelID'])) {
             $context['modelID'] = $req['modelID'];
         }
         //if(isset($req['scriptName']))   $context['scriptName']  = $req['scriptName'];
         setContext($context);
     }
 }
Пример #5
0
*****************************************************************************/
// EVERY *top-level* page must start this way:
// 1. Define it's relationship to the root of the MolProbity installation.
// Pages in subdirectories of lib/ or public_html/ will need more "/.." 's.
if (!defined('MP_BASE_DIR')) {
    define('MP_BASE_DIR', realpath(dirname(__FILE__) . '/..'));
}
// 2. Include core functionality - defines constants, etc.
require_once MP_BASE_DIR . '/lib/core.php';
// 3. Restore session data. If you don't want to access the session
// data for some reason, you must call mpInitEnvirons() instead.
mpStartSession();
// 4. For pages that want to see the session but not change it, such as
// pages that are refreshing periodically to monitor a background job.
mpSessReadOnly();
mpLog("king:User opened a kinemage file in KiNG");
#{{{ a_function_definition - sumary_statement_goes_here
############################################################################
/**
* Documentation for this function.
*/
//function someFunctionName() {}
#}}}########################################################################
# MAIN - the beginning of execution for this page
############################################################################
// Note that changing size breaks the "Close" button, at least in Safari, b/c the page reloads.
if (isset($_REQUEST['size'])) {
    $kingSize = $_REQUEST['size'];
    setcookie('viewking_kingSize', $kingSize);
    // You could get in trouble if a background job was running (hence the check here)
    // or if you somehow hit the size-change link while another page was loading (unlikely),
Пример #6
0
 /**
 * Documentation for this function.
 */
 function onFeedbackSend()
 {
     $req = $_REQUEST;
     $subject = "MolProbity feedback: {$req['inRegardTo']}";
     $msg_text = "\n" . "User name     : {$req['senderName']}\n" . "User email    : {$req['senderEmail']}\n" . "Subject       : {$req['inRegardTo']}\n" . "\n\n" . wordwrap($req['feedbackText'], 76);
     // Write a local copy of the email in case sendmail isn't working
     $tmpfile = tempnam(MP_BASE_DIR . '/feedback', 'email_');
     chmod($tmpfile, 0666 & ~MP_UMASK);
     // tempnam gets wrong permissions sometimes?
     $h = fopen($tmpfile, 'wb');
     fwrite($h, $msg_text);
     fclose($h);
     $ok = mpSendEmail($req['senderName'], $req['senderEmail'], $subject, $msg_text);
     mpLog("feedback:Sent with subject {$req['inRegardTo']}; success={$ok}");
     pageGoto("feedback_done.php", $msg_text);
 }
Пример #7
0
 function onEditPDB()
 {
     $req = $_REQUEST;
     //if($req['cmd'] == 'Cancel')
     if ($req['cmd'] == 'Go back') {
         pageGoto("editpdb_setup1.php");
         return;
     }
     // Otherwise, moving forward:
     $oldID = $req['modelID'];
     $oldModel = $_SESSION['models'][$oldID];
     $inpath = $_SESSION['dataDir'] . '/' . MP_DIR_MODELS . '/' . $oldModel['pdb'];
     $newModel = createModel($oldID . "_edit");
     $newID = $newModel['id'];
     $outpath = $_SESSION['dataDir'] . '/' . MP_DIR_MODELS . '/' . $newModel['pdb'];
     $s = "";
     if (is_array($req['removechain']) && count($req['removechain']) > 0) {
         removeChains($inpath, $outpath, $req['removechain']);
         $s .= "<p>You created {$newModel['pdb']} by removing chain(s) " . implode(', ', $req['removechain']) . " from {$oldModel['pdb']}.\n";
         mpLog("editpdb:Removed chains from a PDB file");
     } else {
         copy($inpath, $outpath);
     }
     $resolu = $req['resolution'] + 0;
     $oldRes = $oldModel['stats']['resolution'] + 0;
     if ($resolu && ($oldRes == 0 || $oldRes != $resolu)) {
         $remark2 = sprintf("REMARK   2                                                                      \nREMARK   2 RESOLUTION. %.2f ANGSTROMS.                                          \n", $resolu);
         replacePdbRemark($outpath, $remark2, 2);
         $s .= "<p>You manually set the resolution for {$newModel['pdb']}.\n";
         mpLog("editpdb:Changed/set resolution for a PDB file");
     }
     if ($req['removeHs']) {
         $newModel = createModel($oldID . "_trimmed");
         $newID = $newModel['id'];
         $outpath = $_SESSION['dataDir'] . '/' . MP_DIR_MODELS . '/' . $newModel['pdb'];
         reduceTrim($inpath, $outpath);
         $s .= "<p>You created {$newModel['pdb']} by removing hydrogens from {$oldModel['pdb']}.\n";
         mpLog("editpdb:Removed hydrogens from a PDB file");
     }
     $newModel['stats'] = pdbstat($outpath);
     $newModel['history'] = "Edited {$oldModel['pdb']}";
     $newModel['isUserSupplied'] = $oldModel['isUserSupplied'];
     $_SESSION['models'][$newID] = $newModel;
     $_SESSION['lastUsedModelID'] = $newID;
     // this is now the current model
     $details = describePdbStats($newModel['stats'], true);
     $s .= "<ul>\n";
     foreach ($details as $detail) {
         $s .= "<li>{$detail}</li>\n";
     }
     $s .= "</ul>\n";
     $entrynum = addLabbookEntry("Created PDB file {$newModel['pdb']}", $s, "{$oldID}|{$newID}", "auto", "scissors.png");
     pageGoto("generic_done.php", array('labbookEntry' => $entrynum));
 }
Пример #8
0
 /**
 * Documentation for this function.
 */
 function onAddH()
 {
     $req = $_REQUEST;
     if ($req['cmd'] == 'Cancel') {
         pageReturn();
         return;
     }
     // Otherwise, moving forward:
     if (isset($req['modelID']) && isset($req['method']) && isset($req['blength'])) {
         unset($_SESSION['bgjob']);
         // Clean up any old data
         $_SESSION['bgjob']['modelID'] = $req['modelID'];
         $_SESSION['bgjob']['makeFlipkin'] = $req['makeFlipkin'];
         $_SESSION['bgjob']['nqh_regularize'] = $req['nqh_regularize'];
         $_SESSION['bgjob']['reduce_blength'] = $req['blength'];
         $_SESSION['reduce_blength'] = $_SESSION['bgjob']['reduce_blength'];
         if ($req['method'] == 'build') {
             if ($_SESSION['bgjob']['reduce_blength'] == 'ecloud') {
                 mpLog("reduce-build:User ran default Reduce -build job; flipkins=" . $_REQUEST['makeFlipkin']);
             } else {
                 mpLog("reduce-build:User ran default Reduce -build -nuclear job; flipkins=" . $_REQUEST['makeFlipkin']);
             }
             // launch background job
             pageGoto("job_progress.php");
             launchBackground(MP_BASE_DIR . "/jobs/reduce-build.php", "reduce_choose.php", 5);
         } elseif ($req['method'] == 'nobuild') {
             if ($_SESSION['bgjob']['reduce_blength'] == 'ecloud') {
                 mpLog("reduce-nobuild:User ran Reduce with -nobuild9999 flag");
             } else {
                 mpLog("reduce-nobuild:User ran Reduce with -nobuild9999 -nuclear flag");
             }
             // launch background job
             pageGoto("job_progress.php");
             launchBackground(MP_BASE_DIR . "/jobs/reduce-nobuild.php", "generic_done.php", 5);
         }
     } else {
         $context = getContext();
         if (isset($req['modelID'])) {
             $context['modelID'] = $req['modelID'];
         }
         if (isset($req['method'])) {
             $context['method'] = $req['method'];
         }
         if (isset($req['blength'])) {
             $context['blength'] = $req['blength'];
         }
         setContext($context);
     }
 }
Пример #9
0
 /**
 * Launches Prekin when the user submits the form.
 */
 function onRunPrekin()
 {
     $req = $_REQUEST;
     if ($req['cmd'] == 'Cancel') {
         pageReturn();
         return;
     }
     // Otherwise, moving forward:
     if (isset($req['modelID']) && isset($req['scriptName'])) {
         $_SESSION['lastUsedModelID'] = $req['modelID'];
         // this is now the current model
         unset($_SESSION['bgjob']);
         // Clean up any old data
         $_SESSION['bgjob'] = $req;
         mpLog("makekin:Creating simple kinemages from built-in Prekin script '{$req['scriptName']}'");
         // launch background job
         pageGoto("job_progress.php");
         launchBackground(MP_BASE_DIR . "/jobs/makekin.php", "generic_done.php", 3);
     } else {
         $context = getContext();
         if (isset($req['modelID'])) {
             $context['modelID'] = $req['modelID'];
         }
         if (isset($req['scriptName'])) {
             $context['scriptName'] = $req['scriptName'];
         }
         setContext($context);
     }
 }
Пример #10
0
function getMaps($code)
{
    global $map_notebook_msg;
    $map_notebook_msg = "";
    $prog = getProgressTasks();
    if ($_SESSION['bgjob']['eds_2fofc']) {
        $prog['2fofc'] = "Download 2Fo-Fc map from the EDS";
    }
    if ($_SESSION['bgjob']['eds_fofc']) {
        $prog['fofc'] = "Download Fo-Fc (difference) map from the EDS";
    }
    $mapDir = "{$_SESSION['dataDir']}/" . MP_DIR_EDMAPS;
    if (!file_exists($mapDir)) {
        mkdir($mapDir, 0777);
    }
    if ($_SESSION['bgjob']['eds_2fofc']) {
        setProgress($prog, '2fofc');
        $mapName = "{$code}.omap.gz";
        $mapPath = "{$mapDir}/{$mapName}";
        if (!file_exists($mapPame)) {
            $tmpMap = getEdsMap($code, 'omap', '2fofc');
            if ($tmpMap && copy($tmpMap, $mapPath)) {
                unlink($tmpMap);
                $_SESSION['edmaps'][$mapName] = $mapName;
                mpLog("edmap-eds:User requested 2Fo-Fc map for {$code} from the EDS");
                $map_notebook_msg .= "<p>The 2Fo-Fc map for {$code} was successfully retrieved from the EDS.</p>\n";
            } else {
                $map_notebook_msg .= "<p><div class='alert'>The 2Fo-Fc map for {$code} could not be retrieved from the EDS.</div></p>\n";
            }
        } else {
            echo "Map file already exists";
        }
    }
    if ($_SESSION['bgjob']['eds_fofc']) {
        setProgress($prog, 'fofc');
        $mapName = "{$code}-diff.omap.gz";
        $mapPath = "{$mapDir}/{$mapName}";
        if (!file_exists($mapPame)) {
            $tmpMap = getEdsMap($code, 'omap', 'fofc');
            if ($tmpMap && copy($tmpMap, $mapPath)) {
                unlink($tmpMap);
                $_SESSION['edmaps'][$mapName] = $mapName;
                mpLog("edmap-eds:User requested Fo-Fc map for {$code} from the EDS");
                $map_notebook_msg .= "<p>The Fo-Fc map for {$code} was successfully retrieved from the EDS.</p>\n";
            } else {
                $map_notebook_msg .= "<p><div class='alert'>The Fo-Fc map for {$code} could not be retrieved from the EDS.</div></p>\n";
            }
        }
    }
    setProgress($prog, null);
}
Пример #11
0
 /**
 * Documentation for this function.
 */
 function onRerunReduce()
 {
     $req = $_REQUEST;
     $doflip = $req['doflip'];
     $modelID = $req['modelID'];
     $model = $_SESSION['models'][$modelID];
     $pdb = $_SESSION['dataDir'] . '/' . MP_DIR_MODELS . '/' . $model['pdb'];
     $url = $_SESSION['dataURL'] . '/' . MP_DIR_MODELS . '/' . $model['pdb'];
     // If all changes were accepted, we will not need to re-run Reduce.
     // We're going to construct a lab notebook entry at the same time.
     $changes = decodeReduceUsermods($pdb);
     $rerun = false;
     $flags = '';
     $n = count($changes[0]);
     // How many changes are in the table?
     $autoflip = "<p>The following residues were flipped automatically by Reduce:\n<ul>\n";
     $userflip = "<p>The following residues were flipped manually by the user:\n<ul>\n";
     $userkeep = "<p>The following residues were NOT flipped, though Reduce recommended doing so:\n<ul>\n";
     for ($c = 0; $c < $n; $c++) {
         // Expect checks for ones flipped originally; expect no check for ones not flipped.
         $expected = $changes[4][$c] == "FLIP" || $changes[4][$c] == "CLS-FL";
         if ($expected) {
             if ($doflip[$c]) {
                 $autoflip .= "<li>{$changes[1][$c]} {$changes[2][$c]} {$changes[3][$c]} {$changes[13][$c]}</li>\n";
             } else {
                 $userkeep .= "<li>{$changes[1][$c]} {$changes[2][$c]} {$changes[3][$c]} {$changes[13][$c]}</li>\n";
                 $rerun = true;
             }
         } elseif ($doflip[$c]) {
             $userflip .= "<li>{$changes[1][$c]} {$changes[2][$c]} {$changes[3][$c]} {$changes[13][$c]}</li>\n";
         }
     }
     $autoflip .= "</ul>\n</p>\n";
     $userflip .= "</ul>\n</p>\n";
     $userkeep .= "</ul>\n</p>\n";
     $hcount = countReduceChanges($pdb);
     $parent = $_SESSION['models'][$model['parent']];
     $entry = "Reduce was run on {$parent['pdb']} to add and optimize hydrogens, and optimize Asn, Gln, and His flips, yielding {$model['pdb']}.\n";
     if ($hcount) {
         $entry .= "{$hcount['found']} hydrogens were found in the original model, and {$hcount['add']} hydrogens were added.\n";
         if ($hcount['std']) {
             $entry .= "{$hcount['std']} H were repositioned to standardize bond lengths.\n";
         }
         if ($hcount['adj']) {
             $entry .= "The positions of {$hcount['adj']} hydrogens were adjusted to optimize H-bonding.\n";
         }
     }
     if ($_SESSION['reduce_blength'] == 'ecloud') {
         $flags = 'electron-cloud';
     } else {
         $flags = 'nuclear';
     }
     $entry .= "<p>Reduce placed hydrogens at {$flags} positions.\n";
     $entry .= "<p>Reduce used <a href=http://kinemage.biochem.duke.edu/software/reduce.php> reduce_wwPDB_het_dict.txt </a> as the het dictonary.\n";
     if ($doflip && $n > 0) {
         $entry .= "<p>You can now download this atom-shifted and annotated <a href='{$url}'>PDB file with hydrogens</a>";
         $entry .= " or <a href='download_trimmed.php?{$_SESSION['sessTag']}&file={$pdb}'>without hydrogens (flips only)</a> <b>which should be re-refined before deposition.</b></p>\n";
     } else {
         $entry .= "<p>You can now download the optimized and annotated <a href='{$url}'>PDB file with hydrogens</a>";
         $entry .= " or <a href='download_trimmed.php?{$_SESSION['sessTag']}&file={$pdb}'>without hydrogens (flips only)</a>.</p>\n";
     }
     $nqkin = $_SESSION['dataDir'] . '/' . MP_DIR_KINS . "/{$model['prefix']}flipnq.kin";
     $hiskin = $_SESSION['dataDir'] . '/' . MP_DIR_KINS . "/{$model['prefix']}fliphis.kin";
     if (file_exists($nqkin) && file_exists($hiskin)) {
         $entry .= "<p>These Flipkin kinemages illustrate both flip states for all Asn/Gln/His.\n";
         $entry .= "Residues that Reduce <i>suggested</i> flipping are marked with stars (*) in the Views menu.\n";
         $entry .= "<ul>\n";
         $entry .= "<li>" . linkKinemage("{$model['prefix']}flipnq.kin") . "</li>\n";
         $entry .= "<li>" . linkKinemage("{$model['prefix']}fliphis.kin") . "</li>\n";
         $entry .= "</ul></p>\n";
     }
     if (strpos($autoflip, "<li>") !== false) {
         $entry .= $autoflip;
     }
     if (strpos($userflip, "<li>") !== false) {
         $entry .= $userflip;
     }
     if (strpos($userkeep, "<li>") !== false) {
         $entry .= $userkeep;
     }
     // Go ahead and make the notebook entry inline -- this can't take more than 1-2 sec.
     if ($_SESSION['reduce_blength'] == 'ecloud') {
         $flags = '-build';
     } else {
         $flags = '-build -nuclear';
     }
     if ($rerun) {
         $title = "Added H with {$flags} and user overrides to get {$model['pdb']}";
     } else {
         $title = "Added H with {$flags} to get {$model['pdb']}";
     }
     unset($_SESSION['bgjob']);
     // Clean up any old data
     $_SESSION['bgjob']['labbookEntry'] = addLabbookEntry($title, $entry, "{$parent['id']}|{$modelID}", "auto", "add_h.png");
     $_SESSION['bgjob']['modelID'] = $_REQUEST['modelID'];
     $_SESSION['bgjob']['doflip'] = $_REQUEST['doflip'];
     // User requested changes; re-launch Reduce
     if ($rerun) {
         mpLog("reduce-custom:User made changes to flips suggested by Reduce -build");
         // launch background job
         pageGoto("job_progress.php");
         launchBackground(MP_BASE_DIR . "/jobs/reduce-fix.php", "reduce_done.php", 5);
     } else {
         mpLog("reduce-accept:User accepted all flips proposed by Reduce -build as-is");
         pageGoto("reduce_done.php", $_SESSION['bgjob']);
     }
 }
Пример #12
0
 /**
 * Documentation for this function.
 */
 function onSetTimezone()
 {
     $req = $_REQUEST;
     if (isset($req['timezone'])) {
         $_SESSION['timeZone'] = $req['timezone'];
         mpLog("timezone:User specified timezone as " . $req['timezone']);
     }
 }
Пример #13
0
 /**
 * Documentation for this function.
 */
 function onUploadHetDictFile()
 {
     if ($_REQUEST['cmd'] == "Cancel") {
         pageReturn();
     } else {
         // Remove the old het dictionary:
         if (isset($_SESSION['hetdict'])) {
             unlink($_SESSION['hetdict']);
             unset($_SESSION['hetdict']);
         }
         $dictName = "user_het_dict.txt";
         $dictPath = "{$_SESSION['dataDir']}/" . MP_DIR_TOPPAR;
         if (!file_exists($dictPath)) {
             mkdir($dictPath, 0777);
         }
         $dictPath .= "/{$dictName}";
         if (!$_FILES['uploadFile']['error'] && $_FILES['uploadFile']['size'] > 0 && move_uploaded_file($_FILES['uploadFile']['tmp_name'], $dictPath)) {
             // Uploaded file probably has restrictive permissions
             chmod($dictPath, 0666 & ~MP_UMASK);
             exec("echo >> {$dictPath}");
             // adds a blank line
             exec("cat " . MP_REDUCE_HET_DICT . " >> {$dictPath}");
             // appends the std dict
             $_SESSION['hetdict'] = $dictName;
             mpLog("hetdict-upload:User uploaded an custom het dictionary file");
             pageGoto("upload_other_done.php", array('type' => 'hetdict'));
         } else {
             $this->doUploadError('hetdict');
         }
     }
 }
Пример #14
0
 /**
 * This function calls the notebook editor so the user can modify the notebook
 * entry. Control is transfered to another page, namely, notebook_edit.php.
 * When that page is done, it will call pageReturn(), and control will return
 * to this class--display() will be called again to show the entry.
 *
 * This function gets called when the user clicks the link made by display()
 *
 * $arg contains the entry number of the notebook entry to edit. It was specified
 * by the call to makeEventURL() that occurs in display(), above.
 * $req is filled in with the usually info from the form submission, but
 * we don't need to use it for anything here.
 */
 function onFillGaps()
 {
     $req = $_REQUEST;
     if ($req['cmd'] == 'Cancel') {
         pageReturn();
         return;
     }
     if (isset($req['modelID'])) {
         $_SESSION['lastUsedModelID'] = $req['modelID'];
         // this is now the current model
         unset($_SESSION['bgjob']);
         // Clean up any old data
         $_SESSION['bgjob'] = $req;
         mpLog("makekin:Filling fragments in: '{$req['modelID']}'");
         // launch background job
         pageGoto("job_progress.php");
         launchBackground(MP_BASE_DIR . "/jobs/fillfragments.php", "generic_done.php", 3);
     } else {
         $context = getContext();
         if (isset($req['modelID'])) {
             $context['modelID'] = $req['modelID'];
         }
         //if(isset($req['scriptName']))   $context['scriptName']  = $req['scriptName'];
         setContext($context);
     }
 }
Пример #15
0
############################################################################
/**
* Documentation for this function.
*/
//function someFunctionName() {}
#}}}########################################################################
# MAIN - the beginning of execution for this page
############################################################################
if (!isset($_REQUEST['fileName']) || !isset($_REQUEST['fileContents'])) {
    die("This page for file uploads only");
}
// First make sure this is a legal file name with no weird chars, ending in .kin
$outname = censorFileName($_REQUEST['fileName'], "kin");
// Now make sure we have a directory to put it in
$outpath = $_SESSION['dataDir'] . '/' . MP_DIR_KINS;
if (!file_exists($outpath)) {
    mkdir($outpath, 0777);
}
// Finally, make sure we don't overwrite anything already in existance!
while (file_exists("{$outpath}/{$outname}" . $serial)) {
    $serial++;
}
$outpath = "{$outpath}/{$outname}" . $serial;
$h = fopen($outpath, 'wb');
fwrite($h, $_REQUEST['fileContents']);
fclose($h);
$size = strlen($_REQUEST['fileContents']);
echo "OK name={$outpath}; size={$size}\n";
// msg for KiNG
mpLog("savekin:User saved a modified kinemage under {$outpath}; size={$size}");
Пример #16
0
 /**
 * Documentation for this function.
 */
 function onRunAnalysis()
 {
     $req = $_REQUEST;
     if ($req['cmd'] == 'Cancel') {
         pageReturn();
         return;
     }
     // Otherwise, moving forward:
     if (isset($req['ensID'])) {
         $_SESSION['lastUsedModelID'] = $req['ensID'];
         // this is now the current "model"
         unset($_SESSION['bgjob']);
         // Clean up any old data
         $_SESSION['bgjob'] = $req;
         mpLog("aacgeom:Running all-atom contact and geometric analyses");
         // The chartXXX vars aren't defined in this interface (yet), but they don't hurt anything...
         if ($req['kinClashes'] || $req['kinHbonds'] || $req['kinContacts'] || $req['chartClashlist']) {
             mpLog("aacgeom-aac:Generataing all-atom contact data of some type");
         }
         if ($req['kinRama'] || $req['chartRama']) {
             mpLog("aacgeom-rama:Doing Ramachandran analysis");
         }
         if ($req['kinRota'] || $req['chartRota']) {
             mpLog("aacgeom-rota:Doing rotamer analysis");
         }
         if ($req['kinCBdev'] || $req['chartCBdev']) {
             mpLog("aacgeom-cbdev:Doing C-beta deviation analysis");
         }
         if ($req['kinBaseP'] || $req['chartBaseP']) {
             mpLog("aacgeom-basep:Validating base-phosphate distances vs sugar puckers");
         }
         // doMultiGraph hasn't been renamed to doCharts yet...
         if ($req['doKinemage']) {
             mpLog("aacgeom-mkin:Multi-criterion validation kinemage");
         }
         //if($req['doCharts'])        mpLog("aacgeom-mchart:Multi-criterion validation chart");
         if ($req['doMultiGraph']) {
             mpLog("aacgeom-mchart:Multi-criterion validation chart");
         }
         // launch background job
         pageGoto("job_progress.php");
         launchBackground(MP_BASE_DIR . "/jobs/ens_aacgeom.php", "generic_done.php", 5);
     }
 }
Пример #17
0
/** Returns true if a new session was created, false otherwise. */
function mpStartSession($createIfNeeded = false)
{
    // First set up constants, env. variables, etc.
    mpInitEnvirons();
    // Cookies cause more trouble than they're worth
    ini_set("session.use_cookies", 0);
    ini_set("session.use_only_cookies", 0);
    // We want to control garbage collection more carefully
    // (MP_SESSION_LIFETIME is a dummy -- lifetime is determined per-session)
    ini_set("session.gc_maxlifetime", MP_SESSION_LIFETIME);
    #ini_set("session.gc_probability", 100);
    // Set up our session name
    session_name(MP_SESSION_NAME);
    // Establish custom routines for persisting session data
    session_set_save_handler("mpSessOpen", "mpSessClose", "mpSessRead", "mpSessWrite", "mpSessDestroy", "mpSessGC");
    // Restore the session data
    @session_start();
    // we get meaningless error msgs when used from a script env.
    mpCheckSessionID(session_id());
    // just in case
    // Check to make sure we have a working directory for this user.
    //$dataDir = MP_BASE_DIR."/public_html/data/".session_id();
    $dataDir = MP_JOB_DATA_DIR . session_id();
    if (!file_exists($dataDir)) {
        if ($createIfNeeded) {
            // Always do cleanup before starting a new session
            // (MP_SESSION_LIFETIME is a dummy -- lifetime is determined per-session)
            mpSessGC(MP_SESSION_LIFETIME);
            // Main data directories
            mkdir($dataDir, 0770);
            // Default mode; is modified by UMASK too.
            mkdir("{$dataDir}/" . MP_DIR_SYSTEM, 0770);
            mkdir("{$dataDir}/tmp", 0770);
            // Others specified in config.php must be created on demand.
            // Set up some session variables. See docs for explanation.
            $_SESSION['dataDir'] = $dataDir;
            $_SESSION['dataURL'] = "data/" . session_id();
            $_SESSION['sessTag'] = session_name() . "=" . session_id();
            $_SESSION['userIP'] = getVisitorIP();
            $_SESSION['timeZone'] = MP_DEFAULT_TIMEZONE;
            $_SESSION['kingSize'] = "default";
            $_SESSION['currEventID'] = 1;
            // used by (optional) MVC/event architecture
            $_SESSION['models'] = array();
            // no models to start with
            $_SESSION['ensembles'] = array();
            // no ensembles to start with
            $_SESSION['reduce_blength'] = "ecloud";
            // x-H distance
            $_SESSION['useSEGID'] = false;
            // TODO: perform other tasks to start a session
            // Create databases, etc, etc.
            //mpLog("new-session:New user session started");
            $sessionCreated = true;
        } else {
            mpLog("badsession:Unknown session with ID '" . session_id() . "'");
            die("Specified session '" . session_id() . "' does not exist.");
        }
    } else {
        $sessionCreated = false;
    }
    // Mark the lifetime of this session
    mpSessSetTTL(session_id(), MP_SESSION_LIFETIME);
    // Also set location of Reduce's heterogen dictionary,
    // overriding the value set up by mpInitEnvirons().
    // Better here than on command line b/c it affects e.g. flipkin too
    if (isset($_SESSION['hetdict'])) {
        putenv("REDUCE_HET_DICT=" . $_SESSION['hetdict']);
    } else {
        putenv("REDUCE_HET_DICT=" . MP_REDUCE_HET_DICT);
    }
    return $sessionCreated;
}
Пример #18
0
// 4. For pages that want to see the session but not change it, such as
// pages that are refreshing periodically to monitor a background job.
mpSessReadOnly();
#{{{ a_function_definition - sumary_statement_goes_here
############################################################################
/**
* Documentation for this function.
*/
//function someFunctionName() {}
#}}}########################################################################
# MAIN - the beginning of execution for this page
############################################################################
// Security check on filename
$file = realpath($_REQUEST['file']);
if (!$file || !startsWith($file, realpath($_SESSION['dataDir']))) {
    mpLog("security:Attempt to access '{$file}' as '{$_REQUEST['file']}'");
    die("Security failure: illegal file request '{$_REQUEST['file']}'");
}
$tmp = mpTempfile('tmp_pdb_trim_');
reduceTrim($file, $tmp);
$name = basename($file);
if (preg_match('/H[0-9]*.pdb$/', $name)) {
    // uses preg_split to split the name into an array with the H from the name missing.
    $nameArray = preg_split('/H([0-9]*.pdb)$/', $name, -1, PREG_SPLIT_DELIM_CAPTURE);
    $name = $nameArray[0] . $nameArray[1];
} elseif (preg_match('/H_reg[0-9]*.pdb$/', $name)) {
    // uses preg_split to split the name into an array with the H from the name missing.
    $nameArray = preg_split('/H_reg([0-9]*.pdb)$/', $name, -1, PREG_SPLIT_DELIM_CAPTURE);
    $name = $nameArray[0] . $nameArray[1];
}
### FUNKY: This turns into a binary file download rather than an HTML page,
Пример #19
0
                $s .= "<p><div class='alert'>The 2Fo-Fc map for {$code} could not be retrieved from the EDS.</div></p>\n";
            }
        } else {
            $s .= "<p><div class='alert'>The 2Fo-Fc map for {$code} could not be retrieved, because a file of the same name already exists.</div></p>\n";
        }
    }
    if ($_SESSION['bgjob']['eds_fofc']) {
        setProgress($prog, 'fofc');
        $mapName = "{$code}-diff.omap.gz";
        $mapPath = "{$mapDir}/{$mapName}";
        if (!file_exists($mapPame)) {
            $tmpMap = getEdsMap($code, 'omap', 'fofc');
            if ($tmpMap && copy($tmpMap, $mapPath)) {
                unlink($tmpMap);
                $_SESSION['edmaps'][$mapName] = $mapName;
                mpLog("edmap-eds:User requested Fo-Fc map for {$code} from the EDS");
                $s .= "<p>The Fo-Fc map for {$code} was successfully retrieved from the EDS.</p>\n";
            } else {
                $s .= "<p><div class='alert'>The Fo-Fc map for {$code} could not be retrieved from the EDS.</div></p>\n";
            }
        } else {
            $s .= "<p><div class='alert'>The Fo-Fc map for {$code} could not be retrieved, because a file of the same name already exists.</div></p>\n";
        }
    }
} else {
    $title = "Failed to retrieve electron density from the EDS";
    $s .= "Unable to retrieve maps from the EDS because '{$code}' is not a valid PDB ID.";
}
// I'm too lazy to put it all the hyperlinks by hand  :)
$s = preg_replace('/EDS/', "<a href='http://eds.bmc.uu.se/' target='_blank'>EDS</a>", $s);
$_SESSION['bgjob']['labbookEntry'] = addLabbookEntry($title, $s, "", "auto", "phe_ed.png");
Пример #20
0
        $funcArgs = $page['handlers'][$eid]['funcArgs'];
        // We use a variable function name here to call the handler.
        //$delegate->$funcName($funcArg, $_REQUEST);
        // Now this is *real* voodoo:
        call_user_func_array(array(&$delegate, $funcName), $funcArgs);
        // In case we changed $_SESSION but display() calls mpSessReadOnly()
        // This save won't stop the session from being automatically saved again
        // after display() and the end of the page.
        // (Though display() shouldn't write to $_SESSION anyway, except events!)
        // However: this can truncate the session file just as a background job
        // is starting, so launchBackground() makes the session read-only,
        // so this call does nothing in that case.
        mpSaveSession();
    } else {
        $GLOBALS['badEventOccurred'] = true;
        mpLog("bad-event:Event ID '{$eid}' is unknown for page {$page['delegate']}. No action taken.");
    }
}
// Clean up from event processing //////////////////////////////////////////////
clearEventHandlers();
// events defined by previous display() are not valid
// Handle a return from a called page //////////////////////////////////////////
// This should now be possible but has not been implemented yet.
// pageReturn() should set global variables ($page_return_callback and _argument)
// and there should be a while() loop here to process multi-level returns.
// Display user interface //////////////////////////////////////////////////////
$page = end($_SESSION['pages']);
// not a ref; read only
$delegate = makeDelegateObject();
// Can't call mpSessReadOnly() or we won't be able to create events.
// Other than events, display() shouldn't write to the session though.
Пример #21
0
 /**
 * Documentation for this function.
 */
 function onRunAnalysis()
 {
     $req = $_REQUEST;
     if ($req['cmd'] == 'Cancel') {
         pageReturn();
         return;
     }
     // Otherwise, moving forward:
     if (isset($req['modelID'])) {
         $_SESSION['lastUsedModelID'] = $req['modelID'];
         // this is now the current model
         unset($_SESSION['bgjob']);
         // Clean up any old data
         $_SESSION['bgjob'] = $req;
         mpLog("aacgeom:Running all-atom contact and geometric analyses");
         if ($req['kinClashes'] || $req['kinHbonds'] || $req['kinContacts'] || $req['chartClashlist']) {
             mpLog("aacgeom-aac:Generataing all-atom contact data of some type");
         }
         if ($req['kinRama'] || $req['chartRama']) {
             mpLog("aacgeom-rama:Doing Ramachandran analysis");
         }
         if ($req['kinRota'] || $req['chartRota']) {
             mpLog("aacgeom-rota:Doing rotamer analysis");
         }
         if ($req['kinGeom'] || $req['chartGeom']) {
             mpLog("aacgeom-geom:Doing geometry analysis");
         }
         if ($req['kinCBdev'] || $req['chartCBdev']) {
             mpLog("aacgeom-cbdev:Doing C-beta deviation analysis");
         }
         if ($req['kinBaseP'] || $req['chartBaseP']) {
             mpLog("aacgeom-basep:Validating base-phosphate distances vs sugar puckers");
         }
         if ($req['kinSuite'] || $req['chartSuite']) {
             mpLog("aacgeom-suite:Validating RNA backbone conformations");
         }
         if ($req['doKinemage']) {
             mpLog("aacgeom-mkin:Multi-criterion validation kinemage");
         }
         if ($req['doCharts']) {
             mpLog("aacgeom-mchart:Multi-criterion validation chart");
         }
         $modelID = $_SESSION['bgjob']['modelID'];
         // $model   = $_SESSION['models'][$modelID];
         if ($req['chartHoriz'] and !isset($_SESSION['models'][$modelID]['mtz_file'])) {
             // check to see if there is one mtz. If so, then link it to the
             // model being analyzed automatically
             $xrayDir = $_SESSION['dataDir'] . '/' . MP_DIR_XRAYDATA;
             if (file_exists($xrayDir)) {
                 $mtzs = array();
                 $handle = opendir($xrayDir);
                 while (false !== ($entry = readdir($handle))) {
                     if (substr($entry, -4) != ".mtz") {
                         continue;
                     }
                     $mtzs[] = $entry;
                 }
                 if (count($mtzs) == 1) {
                     $_SESSION['models'][$modelID]['mtz_file'] = $xrayDir . '/' . $mtzs[0];
                     // launch background job
                     pageGoto("job_progress.php");
                     launchBackground(MP_BASE_DIR . "/jobs/aacgeom.php", "generic_done.php", 5);
                 } else {
                     pageCall("link_model_2_mtz.php", array('modelID' => $modelID));
                 }
             } else {
                 pageCall("link_model_2_mtz.php", array('modelID' => $modelID));
             }
         } else {
             // launch background job
             pageGoto("job_progress.php");
             launchBackground(MP_BASE_DIR . "/jobs/aacgeom.php", "generic_done.php", 5);
         }
     }
 }
Пример #22
0
if (!defined('MP_BASE_DIR')) {
    define('MP_BASE_DIR', realpath(dirname(__FILE__) . '/..'));
}
// 2. Include core functionality - defines constants, etc.
require_once MP_BASE_DIR . '/lib/core.php';
// 3. Restore session data. If you don't want to access the session
// data for some reason, you must call mpInitEnvirons() instead.
mpStartSession();
// 4. For pages that want to see the session but not change it, such as
// pages that are refreshing periodically to monitor a background job.
#mpSessReadOnly();
# MAIN - the beginning of execution for this page
############################################################################
if ($_POST['confirm']) {
    // Must log first or we lose our session ID for the log!
    mpLog("logout-session:User cleaned up all session files and left the site");
    mpDestroySession();
}
// Start the page: produces <HTML>, <HEAD>, <BODY> tags
echo mpPageHeader("Thanks!");
############################################################################
?>
<center>
Thanks for using MolProbity!
All your data files have been erased.
<br>
<br>
<br>
<br>
<a href="index.php"><img src="img/mplogo_clear.png"><br>Start another MolProbity session</a>
<br>
Пример #23
0
 /**
 * Documentation for this function.
 */
 function onAddH()
 {
     $req = $_REQUEST;
     if ($req['cmd'] == 'Cancel') {
         pageReturn();
         return;
     }
     // Otherwise, moving forward:
     if (isset($req['ensID']) && isset($req['method']) && isset($req['blength'])) {
         unset($_SESSION['bgjob']);
         // Clean up any old data
         $_SESSION['bgjob']['ensID'] = $req['ensID'];
         $_SESSION['bgjob']['method'] = $req['method'];
         $_SESSION['bgjob']['reduce_blength'] = $req['blength'];
         mpLog("reduce-ensemble:User ran default Reduce -{$req['method']} job on an ensemble");
         // launch background job
         pageGoto("job_progress.php");
         launchBackground(MP_BASE_DIR . "/jobs/ens_reduce.php", "generic_done.php", 5);
     } else {
         $context = getContext();
         if (isset($req['ensID'])) {
             $context['ensID'] = $req['ensID'];
         }
         if (isset($req['method'])) {
             $context['method'] = $req['method'];
         }
         if (isset($req['blength'])) {
             $context['blength'] = $req['blength'];
         }
         setContext($context);
     }
 }