Esempio n. 1
0
/**
* clash, rota, rama are from the corresponding loadXXX() functions
*/
function getEffectiveResolution($clash, $rota, $rama)
{
    // Use of count(...) may occasionally lead to divide-by-zero if you have
    // non-protein PDB files.  I don't try to trap it b/c the PHP error msg
    // then becomes a useful diagnostic.  (Then $ro or $ra evaluates to unset,
    // and so acts as zero in arithmetic expressions, FWIW.)
    $cs = $clash['scoreAll'];
    $ro = 100.0 * count(findRotaOutliers($rota)) / count($rota);
    $ramaScore = array();
    foreach ($rama as $r) {
        $ramaScore[$r['eval']] += 1;
    }
    $ra = 100.0 - 100.0 * $ramaScore['Favored'] / count($rama);
    //echo " cs=$cs, ro=$ro, ra=$ra ";
    //return 0.4548*log(1+$cs) + 0.4205*log(1+$ro) + 0.3186*log(1+$ra) - 0.5001;
    // We are now working based on a "best feasible structure for your resolution" scale,
    // so all scores = 0 corresponds to a resolution of 0.5 A
    //return 0.4548*log(1+$cs) + 0.4205*log(1+$ro) + 0.3186*log(1+$ra) + 0.5;
    return 0.42574 * log(1 + $cs) + 0.32996 * log(1 + max(0, $ro - 1)) + 0.24979 * log(1 + max(0, $ra - 2)) + 0.5;
}
Esempio n. 2
0
/**
* Composites the results of the find___Outliers() functions into a simple,
* non-redundant list of 9-char residues names (keys)
* and counts of outliers (values).
*/
function findAllOutliers($clash, $rama, $rota, $cbdev, $pperp)
{
    $worst = array();
    #$worst = array_merge($worst, findClashOutliers($clash));
    #$worst = array_merge($worst, findRamaOutliers($rama));
    #$worst = array_merge($worst, findRotaOutliers($rota));
    #$worst = array_merge($worst, findCbetaOutliers($cbdev));
    #$worst = array_merge($worst, findBasePhosPerpOutliers($pperp));
    foreach (array(findClashOutliers($clash), findRamaOutliers($rama), findRotaOutliers($rota), findCbetaOutliers($cbdev), findBasePhosPerpOutliers($pperp)) as $criterion) {
        if (is_array($criterion)) {
            foreach ($criterion as $cnit => $dummy) {
                $worst[$cnit] += 1;
            }
        }
    }
    ksort($worst);
    // Put the residues into a sensible order
    #return array_keys($worst);
    return $worst;
}
Esempio n. 3
0
/**
* $infiles      array of single model PDB files to process
* $outfile      will be overwritten with a kinemage
*/
function writeMultimodelChart($infiles, $outfile)
{
    $infiles = array_values($infiles);
    // re-indexes from 0 ... n-1
    $clashes = array();
    $clashOuts = array();
    $clashCount = array();
    $rotas = array();
    $rotaOuts = array();
    $rotaCount = array();
    $ramas = array();
    $ramaOuts = array();
    $ramaCount = array();
    $tmpfile = mpTempfile();
    for ($i = 0; $i < count($infiles); $i++) {
        runClashlist($infiles[$i], $tmpfile);
        $clashes[$i] = loadClashlist($tmpfile);
        $clashOuts[$i] = findClashOutliers($clashes[$i]);
        foreach ($clashOuts[$i] as $cnit => $junk) {
            $clashCount[$cnit] += 1;
        }
        runRotamer($infiles[$i], $tmpfile);
        $rotas[$i] = loadRotamer($tmpfile);
        $rotaOuts[$i] = findRotaOutliers($rotas[$i]);
        foreach ($rotaOuts[$i] as $cnit => $junk) {
            $rotaCount[$cnit] += 1;
        }
        runRamachandran($infiles[$i], $tmpfile);
        $ramas[$i] = loadRamachandran($tmpfile);
        $ramaOuts[$i] = findRamaOutliers($ramas[$i]);
        foreach ($ramaOuts[$i] as $cnit => $junk) {
            $ramaCount[$cnit] += 1;
        }
    }
    $allRes = array_values(listResidues($infiles[0]));
    // for now, assume all files have same res
    $out = fopen($outfile, 'wb');
    fwrite($out, "@kinemage 1\n");
    fwrite($out, "@flatland\n");
    fwrite($out, "@group {models} animate collapsable\n");
    fwrite($out, "@labellist {res names}\n");
    for ($j = 0; $j < count($allRes); $j++) {
        fwrite($out, "{" . $allRes[$j] . "} 0 -{$j} 0\n");
    }
    fwrite($out, "@balllist {grid} radius= 0.02 nohighlight color= gray\n");
    for ($j = 0; $j < count($allRes); $j++) {
        for ($i = 0; $i < count($infiles); $i++) {
            fwrite($out, "{} " . (-$i - 1) . " -{$j} 0\n");
        }
    }
    for ($i = 0; $i < count($infiles); $i++) {
        fwrite($out, "@subgroup {" . basename($infiles[$i]) . "} dominant\n");
        fwrite($out, "@ringlist {clashes} master= {clashes} radius= 0.3 width= 2 color= hotpink\n");
        for ($j = 0; $j < count($allRes); $j++) {
            if ($clashOuts[$i][$allRes[$j]]) {
                fwrite($out, "{" . $allRes[$j] . "} " . (-$i - 1) . " -{$j} 0\n");
            }
        }
        fwrite($out, "@ringlist {rotamers} master= {rotamers} radius= 0.1 width= 2 color= gold\n");
        for ($j = 0; $j < count($allRes); $j++) {
            if ($rotaOuts[$i][$allRes[$j]]) {
                fwrite($out, "{" . $allRes[$j] . "} " . (-$i - 1) . " -{$j} 0\n");
            }
        }
        fwrite($out, "@ringlist {Ramachandran} master= {Ramachandran} radius= 0.2 width= 2 color= green\n");
        for ($j = 0; $j < count($allRes); $j++) {
            if ($ramaOuts[$i][$allRes[$j]]) {
                fwrite($out, "{" . $allRes[$j] . "} " . (-$i - 1) . " -{$j} 0\n");
            }
        }
    }
    fwrite($out, "@group {criteria (rings)} animate collapsable\n");
    fwrite($out, "@labellist {res names}\n");
    for ($j = 0; $j < count($allRes); $j++) {
        fwrite($out, "{" . $allRes[$j] . "} 0 -{$j} " . -0.1 * $i . "\n");
    }
    for ($i = 0; $i < count($infiles); $i++) {
        fwrite($out, "@subgroup {" . basename($infiles[$i]) . "} dominant\n");
        $xpos = 0;
        fwrite($out, "@ringlist {clashes} radius= " . 0.5 * ($i + 1) / count($infiles) . " width= 1 color= hotpink\n");
        $xpos -= 1.5;
        for ($j = 0; $j < count($allRes); $j++) {
            if ($clashOuts[$i][$allRes[$j]]) {
                fwrite($out, "{" . $allRes[$j] . "} {$xpos} -{$j} " . -0.1 * $i . "\n");
            }
        }
        fwrite($out, "@ringlist {rotamers} radius= " . 0.5 * ($i + 1) / count($infiles) . " width= 1 color= gold\n");
        $xpos -= 1.5;
        for ($j = 0; $j < count($allRes); $j++) {
            if ($rotaOuts[$i][$allRes[$j]]) {
                fwrite($out, "{" . $allRes[$j] . "} {$xpos} -{$j} " . -0.1 * $i . "\n");
            }
        }
        fwrite($out, "@ringlist {Ramachandran} radius= " . 0.5 * ($i + 1) / count($infiles) . " width= 1 color= green\n");
        $xpos -= 1.5;
        for ($j = 0; $j < count($allRes); $j++) {
            if ($ramaOuts[$i][$allRes[$j]]) {
                fwrite($out, "{" . $allRes[$j] . "} {$xpos} -{$j} " . -0.1 * $i . "\n");
            }
        }
    }
    fwrite($out, "@group {criteria (lines)} animate collapsable\n");
    fwrite($out, "@labellist {res names}\n");
    for ($j = 0; $j < count($allRes); $j++) {
        fwrite($out, "{" . $allRes[$j] . "} 0 -{$j} " . -0.1 * $i . "\n");
    }
    $xpos = 0;
    fwrite($out, "@vectorlist {clashes} color= hotpink\n");
    $xpos -= 1;
    writeMultimodelChart_bars($out, $allRes, $clashCount, count($infiles), $xpos);
    fwrite($out, "@vectorlist {rotamers} color= gold\n");
    $xpos -= 1;
    writeMultimodelChart_bars($out, $allRes, $rotaCount, count($infiles), $xpos);
    fwrite($out, "@vectorlist {Ramachandran} color= green\n");
    $xpos -= 1;
    writeMultimodelChart_bars($out, $allRes, $ramaCount, count($infiles), $xpos);
    fwrite($out, "@group {criteria (worms)} animate collapsable\n");
    fwrite($out, "@labellist {res names}\n");
    for ($j = 0; $j < count($allRes); $j++) {
        fwrite($out, "{" . $allRes[$j] . "} 0 -{$j} " . -0.1 * $i . "\n");
    }
    $xpos = 0;
    fwrite($out, "@trianglelist {clashes} color= hotpink\n");
    $xpos -= 1;
    writeMultimodelChart_boxes($out, $allRes, $clashCount, count($infiles), $xpos);
    fwrite($out, "@trianglelist {rotamers} color= gold\n");
    $xpos -= 1;
    writeMultimodelChart_boxes($out, $allRes, $rotaCount, count($infiles), $xpos);
    fwrite($out, "@trianglelist {Ramachandran} color= green\n");
    $xpos -= 1;
    writeMultimodelChart_boxes($out, $allRes, $ramaCount, count($infiles), $xpos);
    fclose($out);
}
Esempio n. 4
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);
}