Beispiel #1
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));
 }
Beispiel #2
0
/**
* $outfile will be overwritten.
* $cnit is an array of CNIT codes for the residues that were processed.
*/
function makeSswingKin($pdb1, $pdb2, $outfile, $cnit)
{
    if (file_exists($outfile)) {
        unlink($outfile);
    }
    $stats = describePdbStats(pdbstat($pdb1), false);
    $h = fopen($outfile, 'a');
    fwrite($h, "@text\n");
    fwrite($h, "Sidechains have been refit by SSWING. Details of the input file:\n\n");
    foreach ($stats as $stat) {
        fwrite($h, "[+]   {$stat}\n");
    }
    fwrite($h, "@kinemage 1\n");
    // Calculate views for each residue in CNIT
    $ctr = computeResCenters($pdb1);
    foreach ($cnit as $res) {
        $i++;
        $c = $ctr[$res];
        fwrite($h, "@{$i}viewid {{$res}}\n@{$i}span 12\n@{$i}zslab 100\n@{$i}center {$c['x']} {$c['y']} {$c['z']}\n");
    }
    fclose($h);
    exec("prekin -quiet -append -animate -onegroup -show 'mc,sc(peach),ca,hy,ht,wa' {$pdb1} >> {$outfile}");
    exec("phenix.probe -quiet -noticks -nogroup -self 'alta' {$pdb1} >> {$outfile}");
    //exec("probe -quiet -noticks -nogroup -self 'alta' $pdb1 >> $outfile");
    exec("prekin -quiet -append -animate -onegroup -show 'mc,sc(sky),ca,hy,ht,wa' {$pdb2} >> {$outfile}");
    exec("phenix.probe -quiet -noticks -nogroup -self 'alta' {$pdb2} >> {$outfile}");
    //exec("probe -quiet -noticks -nogroup -self 'alta' $pdb2 >> $outfile");
}
Beispiel #3
0
/**
* $outfile will be overwritten with a data structure suitable for
*   sortable_table.php; see that code for documentation.
* $snapfile will be overwritten with an HTML snapshot of the unsorted table;
*   if null, this will be skipped.
* $resout is the file name for the table of residue analysis required for horiz
*   chart. if null, this will be skipped.
* $clash    is the data structure from loadClashlist()
* $rama     is the data structure from loadRamachandran()
* $rota     is the data structure from loadRotamer()
* $cbdev    is the data structure from loadCbetaDev()
* $pperp    is the data structure from loadBasePhosPerp()
* $suites   is the data structure from loadSuitenameReport()
* Any of them can be set to null if the data is unavailable.
*/
function writeMulticritChart($infile, $outfile, $snapfile, $resout, $clash, $rama, $rota, $cbdev, $pperp, $suites, $bbonds, $bangles, $cablam, $omega, $outliersOnly = false, $doHtmlTable = true, $cleanupAltloc = true)
{
    $startTime = time();
    //{{{ Process validation data
    // Make sure all residues are represented, and in the right order.
    $res = listResidues($infile);
    //foreach($res as $k => $v)
    //{
    //  echo $k.$v."\n";
    //}
    $alts = mapAlternates($res);
    //foreach($alts as $k => $v)
    //{
    //  foreach($alts[$k] as $i => $j)
    //  {
    //    echo $k.$j."\n";
    //  }
    //}
    $Bfact = listResidueBfactors($infile);
    $Bfact = $Bfact['res'];
    $orderIndex = 0;
    // used to maintain original PDB order on sorting.
    foreach ($res as $k => $v) {
        $res[$k] = array('cnit' => $v, 'order' => $orderIndex++, 'resHiB' => $Bfact[$v]);
    }
    $cell_color_mild = '#ffb3cc';
    $cell_color_bad = '#ff76a9';
    //this is used for all xxx_isbad not set otherwise
    $cell_color_severe = '#ee4d4d';
    if (is_array($clash)) {
        $with = $clash['clashes-with'];
        foreach ($clash['clashes'] as $cnit => $worst) {
            $res[$cnit]['clash_val'] = $worst;
            $res[$cnit]['clash'] = sprintf("%.2f", $worst) . "&Aring;<br><small>" . $with[$cnit]['srcatom'] . " with " . $with[$cnit]['dstcnit'] . " " . $with[$cnit]['dstatom'] . "</small>";
            $res[$cnit]['clash_isbad'] = true;
            $res[$cnit]['any_isbad'] = true;
            if ($res[$cnit]['clash_val'] < 0.5) {
                $res[$cnit]['clash_color'] = $cell_color_mild;
            } elseif ($res[$cnit]['clash_val'] > 0.9) {
                $res[$cnit]['clash_color'] = $cell_color_severe;
            }
            //$res[$cnit]['clash_color'] = '#ff3333';
            //echo "clash ".$cnit."\n";
        }
    }
    //}}}
    if (is_array($rama)) {
        foreach ($rama as $item) {
            $res[$item['resName']]['rama_val'] = $item['scorePct'];
            $phipsi = sprintf("%.1f,%.1f", $item['phi'], $item['psi']);
            if (isset($item['type'])) {
                if ($item['eval'] == "OUTLIER") {
                    $res[$item['resName']]['rama'] = "{$item['eval']} ({$item['scorePct']})%)<br><small>{$item['type']} / {$phipsi}</small>";
                    $res[$item['resName']]['rama_isbad'] = true;
                    $res[$item['resName']]['any_isbad'] = true;
                    // ensures that all outliers sort to the top, b/c 0.2 is a Gly outlier but not a General outlier
                    $res[$item['resName']]['rama_val'] -= 100.0;
                } elseif ($item['eval'] == "Allowed") {
                    $res[$item['resName']]['rama'] = "{$item['eval']} ({$item['scorePct']}%)<br><small>{$item['type']} / {$phipsi}</small>";
                    $res[$item['resName']]['rama_isbad'] = true;
                    $res[$item['resName']]['any_isbad'] = true;
                    $res[$item['resName']]['rama_color'] = $cell_color_mild;
                    // ensures that all outliers sort to the top, b/c 0.2 is a Gly outlier but not a General outlier
                    //$res[$item['resName']]['rama_val'] -= 100.0;
                    $res[$item['resName']]['rama_val'] -= 50.0;
                } else {
                    $res[$item['resName']]['rama'] = "{$item['eval']} ({$item['scorePct']}%)<br><small>{$item['type']} / {$phipsi}</small>";
                }
            }
        }
    }
    //}}}
    if (is_array($rota)) {
        foreach ($rota as $item) {
            $res[$item['resName']]['rota_val'] = $item['scorePct'];
            #if($item['scorePct'] <= 1.0)
            if ($item['eval'] == 'OUTLIER') {
                $res[$item['resName']]['rota'] = "{$item['eval']} ({$item['scorePct']}%)<br><small>chi angles: " . formatChiAngles($item) . "</small>";
                $res[$item['resName']]['rota_isbad'] = true;
                $res[$item['resName']]['any_isbad'] = true;
                $res[$item['resName']]['rota_val'] -= 100.0;
                //sorting hack
            } elseif ($item['eval'] == 'Allowed') {
                $res[$item['resName']]['rota'] = "{$item['eval']} ({$item['scorePct']}%) <i>{$item['rotamer']}</i><br><small>chi angles: " . formatChiAngles($item) . "</small>";
                $res[$item['resName']]['rota_color'] = $cell_color_mild;
                $res[$item['resName']]['rota_val'] -= 50.0;
                //sorting hack
            } else {
                $res[$item['resName']]['rota'] = "{$item['eval']} ({$item['scorePct']}%) <i>{$item['rotamer']}</i><br><small>chi angles: " . formatChiAngles($item) . "</small>";
            }
        }
    }
    //}}}
    if (is_array($cablam)) {
        //note: sorting keys off of cablam_val
        foreach ($cablam as $item) {
            $outlierType = trim($item['outlierType']);
            if ($outlierType == "CaBLAM Outlier") {
                $res[$item['resName']]['cablam'] = "{$item['outlierType']} ({$item['cablamScore']}%)<br><small>{$item['secStruc']}</small>";
                $res[$item['resName']]['cablam_val'] = "{$item['cablamScore']}";
                $res[$item['resName']]['any_isbad'] = true;
                $res[$item['resName']]['cablam_isbad'] = true;
                //$res[$item['resName']]['cablam_color'] = '#ff6699';
            } elseif ($outlierType == "CaBLAM Disfavored") {
                $res[$item['resName']]['cablam'] = "{$item['outlierType']} ({$item['cablamScore']}%)<br><small>{$item['secStruc']}</small>";
                $res[$item['resName']]['cablam_val'] = "{$item['cablamScore']}";
                $res[$item['resName']]['any_isbad'] = true;
                $res[$item['resName']]['cablam_isbad'] = true;
                $res[$item['resName']]['cablam_color'] = $cell_color_mild;
            } elseif ($outlierType == "CA Geom Outlier") {
                $res[$item['resName']]['cablam'] = "{$item['outlierType']} ({$item['caGeomScore']}%)";
                $res[$item['resName']]['cablam_val'] = "{$item['caGeomScore']}";
                $res[$item['resName']]['any_isbad'] = true;
                $res[$item['resName']]['cablam_isbad'] = true;
                //$res[$item['resName']]['cablam_color'] = '#999999';//dark grey
                $res[$item['resName']]['cablam_color'] = $cell_color_severe;
            } else {
                $secStruc = ltrim(trim($item['secStruc']), 'try');
                $res[$item['resName']]['cablam'] = "Favored ({$item['cablamScore']}%)<br><small>{$secStruc}</small>";
                $res[$item['resName']]['cablam_val'] = "{$item['cablamScore']}";
            }
        }
    }
    //}}}
    if (is_array($cbdev)) {
        foreach ($cbdev as $item) {
            $res[$item['resName']]['cbdev_val'] = $item['dev'];
            if ($item['dev'] >= 0.25) {
                $res[$item['resName']]['cbdev'] = sprintf("%.2f", $item['dev']) . "&Aring;";
                $res[$item['resName']]['cbdev_isbad'] = true;
                $res[$item['resName']]['any_isbad'] = true;
                if ($item['dev'] >= 0.7) {
                    $res[$item['resName']]['cbdev_color'] = $cell_color_severe;
                }
            } else {
                if ($res[$item['resName']]['cbdev'] == null) {
                    //for fixing a bug where an ok alt conf dev would get reported instead of the bad dev.
                    $res[$item['resName']]['cbdev'] = sprintf("%.2f", $item['dev']) . "&Aring;";
                }
            }
        }
    }
    //}}}
    if (is_array($omega)) {
        foreach ($omega as $item) {
            if ($item['conf'] == 'Cis') {
                $res[$item['resName']]['any_isbad'] = true;
                if ($item['type'] == 'General') {
                    $res[$item['resName']]['omega'] = "{$item['conf']} nonPRO<br><small>omega= {$item['omega']}</small>";
                    $res[$item['resName']]['omega_val'] = "1";
                    //for column sort
                    $res[$item['resName']]['omega_isbad'] = true;
                } elseif ($item['type'] == 'Pro') {
                    $res[$item['resName']]['omega'] = "{$item['conf']} PRO<br><small>omega= {$item['omega']}</small>";
                    $res[$item['resName']]['omega_val'] = "2";
                    //for column sort
                }
            } elseif ($item['conf'] == 'Twisted') {
                $res[$item['resName']]['any_isbad'] = true;
                $res[$item['resName']]['omega_isbad'] = true;
                if ($item['type'] == 'General') {
                    $res[$item['resName']]['omega'] = "{$item['conf']} nonPRO<br><small>omega= {$item['omega']}</small>";
                    $res[$item['resName']]['omega_val'] = "1";
                } elseif ($item['type'] == 'Pro') {
                    $res[$item['resName']]['omega'] = "{$item['conf']} PRO<br><small>omega= {$item['omega']}</small>";
                    $res[$item['resName']]['omega_val'] = "1";
                }
                //for column sort
            }
        }
    }
    //}}}
    if (is_array($pperp)) {
        foreach ($pperp as $item) {
            if ($item['outlier']) {
                //echo "pperp ".$item['resName']."\n";
                $reasons = array();
                if ($item['deltaOut'] && $item['epsilonOut']) {
                    $reasons[] = "&delta; & &epsilon; outlier <br><small>(P-perp distance implies {$item['probpucker']})</small>";
                } elseif ($item['deltaOut']) {
                    $reasons[] = "&delta; outlier <br><small>(P-perp distance implies {$item['probpucker']})</small>";
                } elseif ($item['epsilonOut']) {
                    $reasons[] = "&epsilon; outlier <br><small>(P-perp distance implies {$item['probpucker']})</small>";
                }
                $res[$item['resName']]['pperp_val'] = 1;
                // no way to quantify this
                $res[$item['resName']]['pperp'] = "suspect sugar pucker  -  " . implode(", ", $reasons) . "";
                $res[$item['resName']]['pperp_isbad'] = true;
                $res[$item['resName']]['any_isbad'] = true;
            }
        }
    }
    //}}}
    if (is_array($suites)) {
        foreach ($suites as $cnit => $item) {
            $res[$cnit]['suites_val'] = $item['suiteness'];
            $bin = "&delta;-1&delta;&gamma; {$item['bin']}";
            if ($bin == '&delta;-1&delta;&gamma; trig') {
                $bin = "&delta;-1&delta;&gamma; none (triaged  {$item['triage']}  )";
                $res[$cnit]['suites_val'] = -1;
                // sorts to very top
            } elseif ($bin == '&delta;-1&delta;&gamma; inc ') {
                $bin = '&delta;-1&delta;&gamma; none (incomplete)';
                $res[$cnit]['suites_val'] = 0.0001;
                // sorts just below all outliers
            } elseif (preg_match('/7D dist/', $item['triage'])) {
                $bin = "{$bin} ( {$item['triage']} )";
            }
            //echo $cnit."\n";
            if ($item['isOutlier']) {
                $res[$cnit]['suites'] = "OUTLIER<br><small>{$bin}</small>";
                $res[$cnit]['suites_isbad'] = true;
                $res[$cnit]['any_isbad'] = true;
            } elseif ($item['bin'] == 'inc ') {
                $res[$cnit]['suites'] = "conformer: {$item['conformer']}<br><small>{$bin}</small>";
            } else {
                $res[$cnit]['suites'] = "conformer: {$item['conformer']}<br><small>{$bin}, suiteness = " . sprintf("%.2f", $item[suiteness]) . "</small>";
            }
        }
    }
    //}}}
    if (is_array($bbonds)) {
        //{{{
        foreach ($bbonds as $cnit => $item) {
            if ($item['isOutlier']) {
                $res[$cnit]['bbonds_val'] = abs($item['sigma']);
                $res[$cnit]['bbonds'] = "{$item['count']} OUTLIER(S)<br><small>worst is {$item['measure']}: " . sprintf("%.1f", $item[sigma]) . " &sigma;</small>";
                $res[$cnit]['bbonds_isbad'] = true;
                $res[$cnit]['any_isbad'] = true;
                if ($res[$cnit]['bbonds_val'] >= 10) {
                    $res[$cnit]['bbonds_color'] = $cell_color_severe;
                }
            }
        }
    }
    //}}}
    if (is_array($bangles)) {
        //{{{
        foreach ($bangles as $cnit => $item) {
            if ($item['isOutlier']) {
                $res[$cnit]['bangles_val'] = abs($item['sigma']);
                $res[$cnit]['bangles'] = "{$item['count']} OUTLIER(S)<br><small>worst is {$item['measure']}: " . sprintf("%.1f", $item[sigma]) . " &sigma;</small>";
                $res[$cnit]['bangles_isbad'] = true;
                $res[$cnit]['any_isbad'] = true;
                if ($res[$cnit]['bangles_val'] >= 10) {
                    $res[$cnit]['bangles_color'] = $cell_color_severe;
                }
            }
        }
    }
    //}}}
    //}}} Process validation data
    //echo "Processing validation data took ".(time() - $startTime)." seconds\n";
    //{{{check for alternates
    foreach ($res as $cnit => $current) {
        $altloc = substr($cnit, 7, 1);
        if ($altloc != ' ') {
            $b_key = substr($cnit, 0, 7) . ' ' . substr($cnit, 8, 3);
            if (isset($res[$b_key])) {
                //{{{clash
                if (!isset($res[$cnit]['clash'])) {
                    $res[$cnit]['clash_val'] = $res[$b_key]['clash_val'];
                    $res[$cnit]['clash'] = $res[$b_key]['clash'];
                    $res[$cnit]['clash_isbad'] = $res[$b_key]['clash_isbad'];
                    $res[$cnit]['any_isbad'] = $res[$b_key]['any_isbad'];
                }
                //}}}
                //{{{rama
                if (!isset($res[$cnit]['rama'])) {
                    $res[$cnit]['rama_val'] = $res[$b_key]['rama_val'];
                    $res[$cnit]['rama'] = $res[$b_key]['rama'];
                    if (isset($res[$b_key]['rama_isbad'])) {
                        $res[$cnit]['rama_isbad'] = $res[$b_key]['rama_isbad'];
                        $res[$cnit]['any_isbad'] = $res[$b_key]['any_isbad'];
                    }
                }
                //}}}
                //{{{rota
                if (!isset($res[$cnit]['rota'])) {
                    $res[$cnit]['rota_val'] = $res[$b_key]['rota_val'];
                    $res[$cnit]['rota'] = $res[$b_key]['rota'];
                    if (isset($res[$b_key]['rota_isbad'])) {
                        $res[$cnit]['rota_isbad'] = $res[$b_key]['rota_isbad'];
                        $res[$cnit]['any_isbad'] = $res[$b_key]['any_isbad'];
                    }
                }
                //}}}
                //{{{cbdev
                if (!isset($res[$cnit]['cbdev_val'])) {
                    $res[$cnit]['cbdev_val'] = $res[$b_key]['cbdev_val'];
                    $res[$cnit]['cbdev'] = $res[$b_key]['cbdev'];
                    if (isset($res[$b_key]['rama_isbad'])) {
                        $res[$cnit]['cbdev_isbad'] = $res[$b_key]['cbdev_isbad'];
                        $res[$cnit]['any_isbad'] = $res[$b_key]['any_isbad'];
                    }
                }
                //}}}
                //{{{pperp
                if (!isset($res[$cnit]['pperp'])) {
                    if (isset($res[$b_key]['pperp'])) {
                        $res[$cnit]['pperp_val'] = $res[$b_key]['pperp_val'];
                        $res[$cnit]['pperp'] = $res[$b_key]['pperp'];
                        $res[$cnit]['pperp_isbad'] = $res[$b_key]['pperp_isbad'];
                        $res[$cnit]['any_isbad'] = $res[$b_key]['any_isbad'];
                    }
                }
                //}}}
                //{{{suites
                if (!isset($res[$cnit]['suites'])) {
                    $res[$cnit]['suites_val'] = $res[$b_key]['suites_val'];
                    $res[$cnit]['suites'] = $res[$b_key]['suites'];
                    if (isset($res[$b_key]['suites_isbad'])) {
                        $res[$cnit]['suites_isbad'] = $res[$b_key]['suites_isbad'];
                        $res[$cnit]['any_isbad'] = $res[$b_key]['any_isbad'];
                    }
                }
                //}}}
                //{{{bbonds
                if (!isset($res[$cnit]['bbonds'])) {
                    if (isset($res[$b_key]['bbonds_isbad'])) {
                        $res[$cnit]['bbonds_val'] = $res[$b_key]['bbonds_val'];
                        $res[$cnit]['bbonds'] = $res[$b_key]['bbonds'];
                        $res[$cnit]['bbonds_isbad'] = $res[$b_key]['bbonds_isbad'];
                        $res[$cnit]['any_isbad'] = $res[$b_key]['any_isbad'];
                    }
                }
                //}}}
                //{{{bangles
                if (!isset($res[$cnit]['bangles'])) {
                    if (isset($res[$b_key]['bangles_isbad'])) {
                        $res[$cnit]['bangles_val'] = $res[$b_key]['bangles_val'];
                        $res[$cnit]['bangles'] = $res[$b_key]['bangles'];
                        $res[$cnit]['bangles_isbad'] = $res[$b_key]['bangles_isbad'];
                        $res[$cnit]['any_isbad'] = $res[$b_key]['any_isbad'];
                    }
                }
                //}}}
                //{{{omega
                if (isset($res[$cnit]['omega'])) {
                    if (isset($res[$b_key]['omega_isbad'])) {
                        $res[$cnit]['omega_val'] = $res[$b_key]['omega_val'];
                        $res[$cnit]['omega'] = $res[$b_key]['omega'];
                        $res[$cnit]['omega_isbad'] = $res[$b_key]['omega_isbad'];
                        $res[$cnit]['any_isbad'] = $res[$b_key]['any_isbad'];
                    }
                }
                //}}}
                //{{{Bfactor
                if (isset($res[$b_key]['resHiB'])) {
                    $res[$cnit]['resHiB'] = max($res[$cnit]['resHiB'], $res[$b_key]['resHiB']);
                }
                //}}}
                //{{{CaBLAM
                if (isset($res[$cnit]['cablam'])) {
                    if (isset($res[$b_key]['cablam_isbad'])) {
                        $res[$cnit]['cablam_val'] = $res[$b_key]['cablam_val'];
                        $res[$cnit]['cablam'] = $res[$b_key]['cablam'];
                        $res[$cnit]['cablam_isbad'] = $res[$b_key]['cablam_isbad'];
                    }
                }
                //}}}
            }
        }
    }
    //}}}
    //remove redundant ' ' entries for residues with alternates
    if ($cleanupAltloc) {
        foreach ($alts as $cnit => $alt) {
            foreach ($alts[$cnit] as $i => $j) {
                $b_key = substr($cnit, 0, 7) . ' ' . substr($cnit, 8, 3);
                unset($res[$b_key]);
            }
        }
    }
    //foreach ($bbonds as $cnit => $alt)
    //{
    //  echo $bbonds[$cnit]['resName']."\n";
    //}
    // $res needs to be saved in raw_data for the horoizontal chart
    if ($resout) {
        $out = fopen($resout, 'wb');
        fwrite($out, mpSerialize($res));
        fclose($out);
    }
    // Set up output data structure
    $table = array('prequel' => '', 'headers' => array(), 'rows' => array(), 'footers' => array(), 'sequel' => '');
    $startTime = time();
    //{{{ Table prequel and headers
    // Do summary chart
    $pdbstats = pdbstat($infile);
    $table['prequel'] = makeSummaryStatsTable($pdbstats['resolution'], $clash, $rama, $rota, $cbdev, $pperp, $suites, $bbonds, $bangles, $cablam, $omega);
    if ($doHtmlTable) {
        $header1 = array();
        $header1[] = array('html' => "<b>#</b>", 'sort' => 1);
        $header1[] = array('html' => "<b>Alt</b>", 'sort' => 1);
        $header1[] = array('html' => "<b>Res</b>", 'sort' => 1);
        $header1[] = array('html' => "<b>High B</b>", 'sort' => -1);
        if (is_array($clash)) {
            $header1[] = array('html' => "<b>Clash &gt; 0.4&Aring;</b>", 'sort' => -1);
        }
        if (is_array($rama)) {
            $header1[] = array('html' => "<b>Ramachandran</b>", 'sort' => 1);
        }
        if (is_array($rota)) {
            $header1[] = array('html' => "<b>Rotamer</b>", 'sort' => 1);
        }
        if (is_array($cbdev)) {
            $header1[] = array('html' => "<b>C&beta; deviation</b>", 'sort' => -1);
        }
        if (is_array($cablam)) {
            $header1[] = array('html' => "<b>CaBLAM</b>", 'sort' => 1);
        }
        if (is_array($pperp)) {
            $header1[] = array('html' => "<b>Base-P perp. dist.</b>", 'sort' => -1);
        }
        if (is_array($suites)) {
            $header1[] = array('html' => "<b>RNA suite conf.</b>", 'sort' => 1);
        }
        if (is_array($bbonds)) {
            $header1[] = array('html' => "<b>Bond lengths</b>", 'sort' => -1);
        }
        if (is_array($bangles)) {
            $header1[] = array('html' => "<b>Bond angles</b>", 'sort' => -1);
        }
        if (is_array($omega)) {
            $header1[] = array('html' => "<b>Cis Peptides</b>", 'sort' => 1);
        }
        $header2 = array();
        $header2[] = array('html' => "");
        $header2[] = array('html' => "");
        $header2[] = array('html' => "");
        $header2[] = array('html' => sprintf("Avg: %.2f", array_sum($Bfact) / count($Bfact)));
        if (is_array($clash)) {
            $header2[] = array('html' => "Clashscore: {$clash['scoreAll']}");
        }
        if (is_array($rama)) {
            $header2[] = array('html' => "Outliers: " . count(findRamaOutliers($rama)) . " of " . findAltTotal($rama));
        }
        if (is_array($rota)) {
            $header2[] = array('html' => "Poor rotamers: " . count(findRotaOutliers($rota)) . " of " . findAltTotal($rota));
        }
        if (is_array($cbdev)) {
            $header2[] = array('html' => "Outliers: " . count(findCbetaOutliers($cbdev)) . " of " . findAltTotal($cbdev));
        }
        if (is_array($cablam)) {
            $header2[] = array('html' => "Outliers: " . count(findCablamOutliers($cablam)) . " of " . findAltTotal($cablam));
        }
        if (is_array($pperp)) {
            $header2[] = array('html' => "Outliers: " . count(findBasePhosPerpOutliers($pperp)) . " of " . findAltTotal($pperp));
        }
        if (is_array($suites)) {
            $header2[] = array('html' => "Outliers: " . count(findSuitenameOutliers($suites)) . " of " . findAltTotal($suites));
        }
        if (is_array($bbonds)) {
            $header2[] = array('html' => "Outliers: " . count(findGeomOutliers($bbonds)) . " of " . findAltTotal($bbonds));
        }
        if (is_array($bangles)) {
            $header2[] = array('html' => "Outliers: " . count(findGeomOutliers($bangles)) . " of " . findAltTotal($bangles));
        }
        if (is_array($omega)) {
            $header2[] = array('html' => "Non-Trans: " . count(findOmegaOutliers($omega)) . " of " . findAltTotal($omega));
        }
        $table['headers'] = array($header1, $header2);
    }
    //}}} Table prequel and headers
    //echo "Table prequel and headers took ".(time() - $startTime)." seconds\n";
    $startTime = time();
    //{{{ Table body
    if ($doHtmlTable) {
        $rows = array();
        foreach ($res as $cnit => $eval) {
            if ($outliersOnly && !$eval['any_isbad']) {
                continue;
            }
            if (!$_SESSION['useSEGID']) {
                $cni = substr($cnit, 0, 7);
                $alt = substr($cnit, 7, 1);
                $type = substr($cnit, 8, 3);
            } else {
                $cni = substr($cnit, 0, 9);
                $alt = substr($cnit, 9, 1);
                $type = substr($cnit, 10, 3);
            }
            //$cni = "'".$cni."'";
            $row = array();
            //$row[] = array('html' => $cnit,             'sort_val' => $eval['order']+0);
            $row[] = array('html' => $cni, 'sort_val' => $eval['order'] + 0);
            $row[] = array('html' => $alt, 'sort_val' => $alt);
            $row[] = array('html' => $type, 'sort_val' => $type);
            $row[] = array('html' => $eval['resHiB'], 'sort_val' => $eval['resHiB'] + 0);
            foreach (array('clash', 'rama', 'rota', 'cbdev', 'cablam', 'pperp', 'suites', 'bbonds', 'bangles', 'omega') as $type) {
                if (is_array(${$type})) {
                    $cell = array();
                    if (isset($eval[$type])) {
                        $cell['html'] = $eval[$type];
                    } else {
                        $cell['html'] = "-";
                    }
                    if (isset($eval[$type . '_color'])) {
                        $cell['color'] = $eval[$type . '_color'];
                    } elseif (isset($eval[$type . '_isbad'])) {
                        $cell['color'] = $cell_color_bad;
                    }
                    if (isset($eval[$type . '_val'])) {
                        $cell['sort_val'] = $eval[$type . '_val'] + 0;
                    }
                    $row[] = $cell;
                }
            }
            /*
            if(is_array($clash))
            $row[] = array('html' => (isset($eval['clash']) ? $eval['clash'] : "-"),        'sort_val' => $eval['clash_val']+0);
            if(is_array($rama))
            $row[] = array('html' => (isset($eval['rama']) ? $eval['rama'] : "-"),          'sort_val' => $eval['rama_val']+0);
            if(is_array($rota))
            $row[] = array('html' => (isset($eval['rota']) ? $eval['rota'] : "-"),          'sort_val' => $eval['rota_val']+0);
            if(is_array($cbdev))
            $row[] = array('html' => (isset($eval['cbdev']) ? $eval['cbdev'] : "-"),        'sort_val' => $eval['cbdev_val']+0);
            if(is_array($pperp))
            $row[] = array('html' => (isset($eval['pperp']) ? $eval['pperp'] : "-"),        'sort_val' => $eval['pperp_val']+0);
            */
            $rows[] = $row;
        }
        $table['rows'] = $rows;
    }
    //}}} Table body
    //echo "Table body took ".(time() - $startTime)." seconds\n";
    $startTime = time();
    $out = fopen($outfile, 'wb');
    fwrite($out, mpSerialize($table));
    fclose($out);
    //echo "Serializing table took ".(time() - $startTime)." seconds\n";
    // serialize() and unserialize() screw up floating point numbers sometimes.
    // Not only is there a change in precision, but sometimes numbers become INF
    // in some versions of PHP 4, like those shipped with Mac OS X.
    //
    #$tmpfile = $_SESSION['dataDir'].'/'.MP_DIR_RAWDATA.'/table_dump';
    #$out = fopen($tmpfile.'1', 'wb');
    #fwrite($out, var_export($table, true));
    #fclose($out);
    #$time = time();
    #    $out = fopen($tmpfile.'2', 'wb');
    #    fwrite($out, var_export(unserialize(serialize($table)), true));
    #    fclose($out);
    #echo "Dump+load time for serialize: ".(time() - $time)." seconds\n";
    #$time = time();
    #    $out = fopen($tmpfile.'3', 'wb');
    #    fwrite($out, var_export(eval("return ".var_export($table, true).";"), true));
    #    fclose($out);
    #echo "Dump+load time for var_export: ".(time() - $time)." seconds\n";
    # WAY TOO SLOW (all in PHP, no C code):
    #$time = time();
    #    $json = new Services_JSON();
    #    $out = fopen($tmpfile.'4', 'wb');
    #    fwrite($out, var_export($json->decode($json->encode($table)), true));
    #    fclose($out);
    #echo "Dump+load time for JSON: ".(time() - $time)." seconds\n";
    if ($snapfile) {
        $startTime = time();
        $out = fopen($snapfile, 'wb');
        //fwrite($out, formatSortableTable($table, 'DUMMY_URL'));
        fwrite($out, formatSortableTableJS($table));
        fclose($out);
        //echo "Formatting sortable table took ".(time() - $startTime)." seconds\n";
    }
}
Beispiel #4
0
     $_SESSION['bgjob']['isRunning'] = false;
     # there was an error. Let's see if it is an element type issue.
     $errfile = $_SESSION['dataDir'] . "/" . MP_DIR_SYSTEM . "/errors";
     $elementerror = is_elementerror($errfile);
     if ($elementerror) {
         $_SESSION['bgjob']['elementError'] = true;
     }
     $modelerror = is_modelerror($errfile);
     if ($modelerror) {
         $_SESSION['bgjob']['modelError'] = true;
     } else {
         $_SESSION['bgjob']['cctbxError'] = true;
     }
     die;
 }
 $minModel['stats'] = pdbstat($outpath2);
 $minModel['parent'] = $modelID;
 $minModel['modelID_pre_min'] = $newModel['id'];
 // for reduce-fix
 // transfer mtz to reduced model
 if (isset($_SESSION['models'][$modelID]['mtz_file'])) {
     $minModel['mtz_file'] = $_SESSION['models'][$modelID]['mtz_file'];
 }
 if ($reduce_blength == 'ecloud') {
     $minModel['history'] = "Derived from {$model['pdb']} by Reduce -build w/ CCTBX side-chain regularization";
 } elseif ($reduce_blength == 'nuclear') {
     $minModel['history'] = "Derived from {$model['pdb']} by Reduce -build -nuclear w/ CCTBX side-chain regularization";
 }
 $minModel['isUserSupplied'] = $model['isUserSupplied'];
 $minModel['isReduced'] = true;
 $minModel['isBuilt'] = true;
Beispiel #5
0
/**
* Calling this function creates N new models with hydrogens and then
* reassembles them into one new ensemble with H.
*
* Returns the ID of the newly minted ensemble.
*
* $ensID        the ensemble ID for the ensemble to reduce
* $reduceFunc   the function to run on ensemble members: one of
*   'reduceBuild', 'reduceNoBuild', or 'reduceTrim'
*/
function reduceEnsemble($ensID, $reduceFunc = 'reduceNoBuild')
{
    $ens = $_SESSION['ensembles'][$ensID];
    $idList = array();
    $pdbList = array();
    $reduce_blength = $_SESSION['reduce_blength'];
    foreach ($ens['models'] as $modelNum => $modelID) {
        $oldModel = $_SESSION['models'][$modelID];
        $newModel = createModel($modelID . "H");
        $outname = $newModel['pdb'];
        $outpath = $_SESSION['dataDir'] . '/' . MP_DIR_MODELS;
        if (!file_exists($outpath)) {
            mkdir($outpath, 0777);
        }
        // shouldn't ever happen, but might...
        $outpath .= '/' . $outname;
        $inpath = $_SESSION['dataDir'] . '/' . MP_DIR_MODELS . '/' . $oldModel['pdb'];
        // FUNKY: calls the function whose name is stored in the variable $reduceFunc
        $reduceFunc($inpath, $outpath, $reduce_blength);
        $newModel['stats'] = pdbstat($outpath);
        $newModel['parent'] = $modelID;
        $newModel['history'] = "Derived from {$oldModel['pdb']} by {$reduceFunc}";
        $newModel['isUserSupplied'] = $oldModel['isUserSupplied'];
        $newModel['isReduced'] = $reduceFunc != 'reduceTrim';
        $newModel['isBuilt'] = $reduceFunc == 'reduceBuild';
        $_SESSION['models'][$newModel['id']] = $newModel;
        $idList[$modelNum] = $newModel['id'];
        $pdbList[$modelNum] = $outpath;
    }
    $ensemble = createEnsemble($ensID . "H");
    $ensemble['models'] = $idList;
    $ensemble['history'] = "Ensemble of " . count($idList) . " models derived from {$ens['pdb']} by {$reduceFunc}";
    //$newModel['isReduced']  = ($reduceFunc != 'reduceTrim');
    //$newModel['isBuilt']    = ($reduceFunc == 'reduceBuild');
    $ensemble['isReduced'] = $reduceFunc != 'reduceTrim';
    $ensemble['isBuilt'] = $reduceFunc == 'reduceBuild';
    $ensemble['isUserSupplied'] = $ens['isUserSupplied'];
    $joinedModel = joinPdbModels($pdbList);
    copy($joinedModel, $_SESSION['dataDir'] . '/' . MP_DIR_MODELS . '/' . $ensemble['pdb']);
    unlink($joinedModel);
    // Create the ensemble entry
    $id = $ensemble['id'];
    $_SESSION['ensembles'][$id] = $ensemble;
    return $id;
}
Beispiel #6
0
 function onConvertToBiolUnit()
 {
     if ($_SESSION['lastUsedModelID']) {
         $oldID = $_SESSION['lastUsedModelID'];
         $model = $_SESSION['ensembles'][$oldID];
         if (!$model) {
             return;
         }
         $modelDir = $_SESSION['dataDir'] . '/' . MP_DIR_MODELS;
         $infile = "{$modelDir}/{$model['pdb']}";
         $tmpfile = convertModelsToChains($infile);
         $newModel = createModel("{$oldID}-biolunit");
         $newID = $newModel['id'];
         $newModel['stats'] = pdbstat($tmpfile);
         $newModel['history'] = 'Converted from ensemble to biological unit';
         $newModel['isUserSupplied'] = $model['isUserSupplied'];
         if (!file_exists($modelDir)) {
             mkdir($modelDir, 0777);
         }
         copy($tmpfile, "{$modelDir}/{$newModel['pdb']}");
         unlink($tmpfile);
         $_SESSION['models'][$newID] = $newModel;
         $_SESSION['lastUsedModelID'] = $newID;
     }
 }
Beispiel #7
0
function onelinepack($pdbname, $pdbproberesult)
{
    $first = true;
    foreach ($pdbname as $pdb) {
        $pdbstatresults = pdbstat($pdb);
        // call out and figure out how many atoms are in the current model
        $numAtoms = $pdbstatresults['heavyatoms'] + $pdbstatresults['hydrogens'];
        // call out and get number of residues
        $numres = $pdbstatresults['residues'];
        //dots numbers
        $proberesult = shell_exec("phenix.probe -mc -self 'ALL' -ONELINE {$pdb} ");
        //$proberesult = shell_exec("probe -mc -self 'ALL' -ONELINE $pdb ");
        //$proberesult = shell_exec("probe -mc  -stdbonds -self 'ALL' -ONELINE $pdb ");
        // open up the oneline and add in number of atoms and number of residues
        $proberesult = trim($proberesult) . $numAtoms . ':' . $numres . "\n";
        $out = fopen($pdbproberesult, 'a');
        fwrite($out, $proberesult);
        fclose($out);
    }
}
Beispiel #8
0
} elseif ($reduce_blength == 'nuclear') {
    $tasks['reduce'] = "Add H with <code>reduce -nobuild9999 -nuclear</code>";
}
$tasks['notebook'] = "Add entry to lab notebook";
setProgress($tasks, 'reduce');
// updates the progress display if running as a background job
$newModel = createModel($modelID . "H");
$outname = $newModel['pdb'];
$outpath = $_SESSION['dataDir'] . '/' . MP_DIR_MODELS;
if (!file_exists($outpath)) {
    mkdir($outpath, 0777);
}
// shouldn't ever happen, but might...
$outpath .= '/' . $outname;
reduceNoBuild($pdb, $outpath, $reduce_blength);
$newModel['stats'] = pdbstat($outpath);
$newModel['parent'] = $modelID;
if ($reduce_blength == 'ecloud') {
    $newModel['history'] = "Derived from {$model['pdb']} by Reduce -nobuild9999";
}
if ($reduce_blength == 'nuclear') {
    $newModel['history'] = "Derived from {$model['pdb']} by Reduce -nobuild9999 -nuclear";
}
$newModel['isUserSupplied'] = $model['isUserSupplied'];
$newModel['isReduced'] = true;
$_SESSION['models'][$newModel['id']] = $newModel;
$_SESSION['bgjob']['modelID'] = $newModel['id'];
$_SESSION['lastUsedModelID'] = $newModel['id'];
// this is now the current model
$hcount = countReduceChanges($outpath);
setProgress($tasks, 'notebook');
Beispiel #9
0
function makeChartKin($pdbname, $ChartKin)
{
    $caption = "caption goes here";
    $out = fopen($ChartKin, 'w');
    fwrite($out, "@kinemage \n");
    fwrite($out, " \n");
    fwrite($out, " \n");
    fwrite($out, "@onewidth \n");
    fwrite($out, "@viewid {Overview} \n");
    fwrite($out, "@zoom 1.00 \n");
    fwrite($out, "@zslab 200 \n");
    fwrite($out, "@ztran 0 \n");
    fwrite($out, "@center -16.500 -11.500 0.122 \n");
    fwrite($out, "@matrix \n");
    fwrite($out, "1.000000 -0.000000 0.000000 0.000000 1.000000 0.000000 0.000000 -0.000000 1.000000 \n");
    fwrite($out, "@master {Rotamer Outliers} \n");
    fwrite($out, "@master {Rotamer % Outliers} \n");
    fwrite($out, "@master {Global Measure Chart} \n");
    fwrite($out, "@master {Residue Chart} \n");
    fwrite($out, "@labellist {label} color= white master= {Global Measure Chart} nobutton \n");
    fwrite($out, "{Resolution or Constrains per Residue}100.000 -30.000 0.000 \n");
    fwrite($out, "{Value} -30.000 125.000 30.000 \n");
    fwrite($out, "@vectorlist {edge} color= gray width= 1 master= {Global Measure Chart} nobutton \n");
    fwrite($out, "{plot edge}P 0.000 250.000 0.000 \n");
    fwrite($out, "{plot edge}0.000 0.000 0.000 \n");
    fwrite($out, "{plot edge}250.000 0.000 0.000 \n");
    fwrite($out, "{plot edge}250.000 250.000 0.000 \n");
    fwrite($out, "{plot edge}0.000 250.000 0.000 \n");
    fwrite($out, "@labellist {label} color= white master= {Residue Chart} nobutton \n");
    fwrite($out, "{Model} 30.000 -30.000 -125.000 \n");
    fwrite($out, "{Residue Number} -125.000 -30.000 30.000 \n");
    fwrite($out, "@vectorlist {edge} color= gray width= 1 master= {Residue Chart} nobutton \n");
    fwrite($out, "{plot edge}P -250.000  0.000 -250.000 \n");
    fwrite($out, "{plot edge}0.000 0.000 -250.000 \n");
    fwrite($out, "{plot edge}0.000 0.000 0.000 \n");
    fwrite($out, "{plot edge}-250.000 0.000 0.000 \n");
    fwrite($out, "{plot edge}-250.000 0.000 -250.000 \n");
    fwrite($out, "@vectorlist {residue} color= gray width= 1 master= {Residue Chart} nobutton \n");
    fwrite($out, "{tick}P 0.000 0.000 0.000 \n");
    fwrite($out, "{\"}0.000 0.000 10.000 \n");
    fwrite($out, "{\"}P -5.000 0.000 0.000 \n");
    fwrite($out, "{\"}-5.000 0.000 5.000 \n");
    fwrite($out, "{\"}P -10.000 0.000 0.000 \n");
    fwrite($out, "{\"}-10.000 0.000 10.000 \n");
    fwrite($out, "{\"}P -15.000 0.000 0.000 \n");
    fwrite($out, "{\"}-15.000 0.000 5.000 \n");
    fwrite($out, "{\"}P -20.000 0.000 0.000 \n");
    fwrite($out, "{\"}-20.000 0.000 10.000 \n");
    fwrite($out, "{\"}P -25.000 0.000 0.000 \n");
    fwrite($out, "{\"}-25.000 0.000 5.000 \n");
    fwrite($out, "{\"}P -30.000 0.000 0.000 \n");
    fwrite($out, "{\"}-30.000 0.000 10.000 \n");
    fwrite($out, "{\"}P -35.000 0.000 0.000 \n");
    fwrite($out, "{\"}-35.000 0.000 5.000 \n");
    fwrite($out, "{\"}P -40.000 0.000 0.000 \n");
    fwrite($out, "{\"}-40.000 0.000 10.000 \n");
    fwrite($out, "{\"}P -45.000 0.000 0.000 \n");
    fwrite($out, "{\"}-45.000 0.000 5.000 \n");
    fwrite($out, "{\"}P -50.000 0.000 0.000 \n");
    fwrite($out, "{\"}-50.000 0.000 10.000 \n");
    fwrite($out, "{\"}P -55.000 0.000 0.000 \n");
    fwrite($out, "{\"}-55.000 0.000 5.000 \n");
    fwrite($out, "{\"}P -60.000 0.000 0.000 \n");
    fwrite($out, "{\"}-60.000 0.000 10.000 \n");
    fwrite($out, "{\"}P -65.000 0.000 0.000 \n");
    fwrite($out, "{\"}-65.000 0.000 5.000 \n");
    fwrite($out, "{\"}P -70.000 0.000 0.000 \n");
    fwrite($out, "{\"}-70.000 0.000 10.000 \n");
    fwrite($out, "{\"}P -75.000 0.000 0.000 \n");
    fwrite($out, "{\"}-75.000 0.000 5.000 \n");
    fwrite($out, "{\"}P -80.000 0.000 0.000 \n");
    fwrite($out, "{\"}-80.000 0.000 10.000 \n");
    fwrite($out, "{\"}P -85.000 0.000 0.000 \n");
    fwrite($out, "{\"}-85.000 0.000 5.000 \n");
    fwrite($out, "{\"}P -90.000 0.000 0.000 \n");
    fwrite($out, "{\"}-90.000 0.000 10.000 \n");
    fwrite($out, "{\"}P -95.000 0.000 0.000 \n");
    fwrite($out, "{\"}-95.000 0.000 5.000 \n");
    fwrite($out, "{\"}P -100.000 0.000 0.000 \n");
    fwrite($out, "{\"}-100.000 0.000 10.000 \n");
    fwrite($out, "{\"}P -105.000 0.000 0.000 \n");
    fwrite($out, "{\"}-105.000 0.000 5.000 \n");
    fwrite($out, "{\"}P -110.000 0.000 0.000 \n");
    fwrite($out, "{\"}-110.000 0.000 10.000 \n");
    fwrite($out, "{\"}P -115.000 0.000 0.000 \n");
    fwrite($out, "{\"}-115.000 0.000 5.000 \n");
    fwrite($out, "{\"}P -120.000 0.000 0.000 \n");
    fwrite($out, "{\"}-120.000 0.000 10.000 \n");
    fwrite($out, "{\"}P -125.000 0.000 0.000 \n");
    fwrite($out, "{\"}-125.000 0.000 5.000 \n");
    fwrite($out, "{\"}P -130.000 0.000 0.000 \n");
    fwrite($out, "{\"}-130.000 0.000 10.000 \n");
    fwrite($out, "{\"}P -135.000 0.000 0.000 \n");
    fwrite($out, "{\"}-135.000 0.000 5.000 \n");
    fwrite($out, "{\"}P -140.000 0.000 0.000 \n");
    fwrite($out, "{\"}-140.000 0.000 10.000 \n");
    fwrite($out, "{\"}P -145.000 0.000 0.000 \n");
    fwrite($out, "{\"}-145.000 0.000 5.000 \n");
    fwrite($out, "{\"}P -150.000 0.000 0.000 \n");
    fwrite($out, "{\"}-150.000 0.000 10.000 \n");
    fwrite($out, "{\"}P -155.000 0.000 0.000 \n");
    fwrite($out, "{\"}-155.000 0.000 5.000 \n");
    fwrite($out, "{\"}P -160.000 0.000 0.000 \n");
    fwrite($out, "{\"}-160.000 0.000 10.000 \n");
    fwrite($out, "{\"}P -165.000 0.000 0.000 \n");
    fwrite($out, "{\"}-165.000 0.000 5.000 \n");
    fwrite($out, "{\"}P -170.000 0.000 0.000 \n");
    fwrite($out, "{\"}-170.000 0.000 10.000 \n");
    fwrite($out, "{\"}P -175.000 0.000 0.000 \n");
    fwrite($out, "{\"}-175.000 0.000 5.000 \n");
    fwrite($out, "{\"}P -180.000 0.000 0.000 \n");
    fwrite($out, "{\"}-180.000 0.000 10.000 \n");
    fwrite($out, "{\"}P -185.000 0.000 0.000 \n");
    fwrite($out, "{\"}-185.000 0.000 5.000 \n");
    fwrite($out, "{\"}P -190.000 0.000 0.000 \n");
    fwrite($out, "{\"}-190.000 0.000 10.000 \n");
    fwrite($out, "{\"}P -195.000 0.000 0.000 \n");
    fwrite($out, "{\"}-195.000 0.000 5.000 \n");
    fwrite($out, "{\"}P -200.000 0.000 0.000 \n");
    fwrite($out, "{\"}-200.000 0.000 10.000 \n");
    fwrite($out, "{\"}P -205.000 0.000 0.000 \n");
    fwrite($out, "{\"}-205.000 0.000 5.000 \n");
    fwrite($out, "{\"}P -210.000 0.000 0.000 \n");
    fwrite($out, "{\"}-210.000 0.000 10.000 \n");
    fwrite($out, "{\"}P -215.000 0.000 0.000 \n");
    fwrite($out, "{\"}-215.000 0.000 5.000 \n");
    fwrite($out, "{\"}P -220.000 0.000 0.000 \n");
    fwrite($out, "{\"}-220.000 0.000 10.000 \n");
    fwrite($out, "{\"}P -225.000 0.000 0.000 \n");
    fwrite($out, "{\"}-225.000 0.000 5.000 \n");
    fwrite($out, "{\"}P -230.000 0.000 0.000 \n");
    fwrite($out, "{\"}-230.000 0.000 10.000 \n");
    fwrite($out, "{\"}P -235.000 0.000 0.000 \n");
    fwrite($out, "{\"}-235.000 0.000 5.000 \n");
    fwrite($out, "{\"}P -240.000 0.000 0.000 \n");
    fwrite($out, "{\"}-240.000 0.000 10.000 \n");
    fwrite($out, "{\"}P -245.000 0.000 0.000 \n");
    fwrite($out, "{\"}-245.000 0.000 5.000 \n");
    fwrite($out, "{\"}P -250.000 0.000 0.000 \n");
    fwrite($out, "{\"}-250.000 0.000 10.000 \n");
    fwrite($out, "@vectorlist {Model} color= gray width= 1 master= {Residue Chart} nobutton \n");
    fwrite($out, "{tick}P 0.000 0.000 0.000 \n");
    fwrite($out, "{\"}10.000 0.000 0.000 \n");
    fwrite($out, "{\"}P 0.000 0.000 -10.000 \n");
    fwrite($out, "{\"}5.000 0.000 -10.000 \n");
    fwrite($out, "{\"}P 0.000 0.000 -20.000 \n");
    fwrite($out, "{\"}5.000 0.000 -20.000 \n");
    fwrite($out, "{\"}P 0.000 0.000 -30.000 \n");
    fwrite($out, "{\"}5.000 0.000 -30.000 \n");
    fwrite($out, "{\"}P 0.000 0.000 -40.000 \n");
    fwrite($out, "{\"}5.000 0.000 -40.000 \n");
    fwrite($out, "{\"}P 0.000 0.000 -50.000 \n");
    fwrite($out, "{\"}10.000 0.000 -50.000 \n");
    fwrite($out, "{\"}P 0.000 0.000 -60.000 \n");
    fwrite($out, "{\"}5.000 0.000 -60.000 \n");
    fwrite($out, "{\"}P 0.000 0.000 -70.000 \n");
    fwrite($out, "{\"}5.000 0.000 -70.000 \n");
    fwrite($out, "{\"}P 0.000 0.000 -80.000 \n");
    fwrite($out, "{\"}5.000 0.000 -80.000 \n");
    fwrite($out, "{\"}P 0.000 0.000 -90.000 \n");
    fwrite($out, "{\"}5.000 0.000 -90.000 \n");
    fwrite($out, "{\"}P 0.000 0.000 -100.000 \n");
    fwrite($out, "{\"}10.000 0.000 -100.000 \n");
    fwrite($out, "{\"}P 0.000 0.000 -110.000 \n");
    fwrite($out, "{\"}5.000 0.000 -110.000 \n");
    fwrite($out, "{\"}P 0.000 0.000 -120.000 \n");
    fwrite($out, "{\"}5.000 0.000 -120.000 \n");
    fwrite($out, "{\"}P 0.000 0.000 -130.000 \n");
    fwrite($out, "{\"}5.000 0.000 -130.000 \n");
    fwrite($out, "{\"}P 0.000 0.000 -140.000 \n");
    fwrite($out, "{\"}5.000 0.000 -140.000 \n");
    fwrite($out, "{\"}P 0.000 0.000 -150.000 \n");
    fwrite($out, "{\"}10.000 0.000 -150.000 \n");
    fwrite($out, "{\"}P 0.000 0.000 -160.000 \n");
    fwrite($out, "{\"}5.000 0.000 -160.000 \n");
    fwrite($out, "{\"}P 0.000 0.000 -170.000 \n");
    fwrite($out, "{\"}5.000 0.000 -170.000 \n");
    fwrite($out, "{\"}P 0.000 0.000 -180.000 \n");
    fwrite($out, "{\"}10.000 0.000 -180.000 \n");
    fwrite($out, "{\"}P 0.000 0.000 -190.000 \n");
    fwrite($out, "{\"}5.000 0.000 -190.000 \n");
    fwrite($out, "{\"}P 0.000 0.000 -200.000 \n");
    fwrite($out, "{\"}10.000 0.000 -200.000 \n");
    fwrite($out, "{\"}P 0.000 0.000 -210.000 \n");
    fwrite($out, "{\"}5.000 0.000 -210.000 \n");
    fwrite($out, "{\"}P 0.000 0.000 -220.000 \n");
    fwrite($out, "{\"}5.000 0.000 -220.000 \n");
    fwrite($out, "{\"}P 0.000 0.000 -230.000 \n");
    fwrite($out, "{\"}5.000 0.000 -230.000 \n");
    fwrite($out, "{\"}P 0.000 0.000 -240.000 \n");
    fwrite($out, "{\"}5.000 0.000 -240.000 \n");
    fwrite($out, "{\"}P 0.000 0.000 -250.000 \n");
    fwrite($out, "{\"}10.000 0.000 -250.000 \n");
    //for each pdb and iterate
    //in the beginning.. there was a model!
    $modelcounter = 1;
    foreach ($pdbname as $pdb) {
        //overall stats needed for each pdb file
        // crystallographic resolution of the model
        $stats = pdbstat($pdb);
        $resolution = $stats['resolution'];
        /*
        $ConstPerRes =
        // NMR constraints per Residue in the model
        */
        //number of res in the model
        $numRes = $stats['residues'];
        // plotting of rotamer outliers along for each model along vs. residue number
        fwrite($out, "@group {" . basename($pdb, ".pdb") . "} animate dominant \n");
        // plot of rotamer outliers
        fwrite($out, "@balllist {Rotamer Outliers} color= white radius= 0.5 master= {Rotamer Outliers} nohilite \n");
        // create unique temp files in current directory
        $tmp1 = tempnam(MP_BASE_DIR . "/tmp", 'graphtemp');
        // calculations for rotamer data
        runRotamer($pdb, $tmp1);
        $rota = loadrotamer($tmp1);
        //plotting rotamer outliers, determining the x (res), y (score), and z (model) values
        //followed by writing them out in the balllist
        $RotaOut = findRotaOutliers($rota);
        // $RotaOut is the the list of outliers and their scores
        foreach ($RotaOut as $ResName => $score) {
            $x = $rota[$ResName]['resNum'] * -1.0;
            $y = round($rota[$ResName]['scorePct'], 2);
            $z = $modelcounter * -10.0;
            // if x = 0, go to next one...
            if ($x == 0) {
                continue;
            }
            fwrite($out, "{" . basename($pdb, ".pdb") . " " . $ResName . "}{$x} {$y} {$z} \n");
        }
        // plotting % rotamer outlier data
        // x is what you plot against, resolution / restraints per res etc
        // y is the percentage of rotamer outliers in the entire model
        // plots the model
        $numRotaOut = count(findRotaOutliers($rota));
        // can include a factor here
        $percentoutlier = round($numRotaOut / $numRes * 100, 2);
        // multiplication by 100 is the scaleing 'fudge' factor
        $x = $resolution * 100;
        // -10.00 another scaling factor
        $z = $modelcounter * -10.0;
        fwrite($out, "@balllist {Rotamer % Outliers} color= white radius= 1.0 master= {Rotamer % Outliers} nohilite \n");
        fwrite($out, "{" . basename($pdb, ".pdb") . " " . $resolution . "A , " . $percentoutlier . "%" . "} {$x} {$percentoutlier} {$z} \n");
        unlink($tmp1);
        //change the Z number which gets multiplied (and hereafter we added another)
        $modelcounter = $modelcounter + 1;
        //end of the for each loop going through the PDB files
    }
    fclose($out);
}