Skip to content

Commit

Permalink
LIMS-1074: Deploy suggestions from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Williams committed Nov 1, 2023
1 parent 929b4bd commit 6d98705
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 23 deletions.
21 changes: 11 additions & 10 deletions api/scripts/mtz2map.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,27 @@ else
if [ -f $1.gz ]; then
mtz=/tmp/$2_$3.mtz
gunzip -c $1.gz > $mtz
else
echo "No mtz file found"
exit
fi
fi

if [ $3 == 'dimple' -o $3 == 'mrbump' ]; then

if [ -f $4 ]; then
pdb=$4
else
if [ -f $4.gz ]; then
pdb=/tmp/$2_$3.pdb
gunzip -c $4.gz > $pdb
else
echo "No pdb file found"
exit
fi
fi

if [ $3 == 'dimple' -o $3 == 'mrbump' ]; then

if [ $3 == 'dimple' ]; then
# fofc2="F1=F SIG1=SIGF PHI=PH2FOFCWT W=FOM"
# fofc="F1=F SIG1=SIGF PHI=PHFOFCWT W=FOM"
# fofc2="F1=F SIG1=SIGF PHI=PHWT W=FOM"
# fofc="F1=F SIG1=SIGF PHI=PHDELWT W=FOM"

if $root/mtzinfo $mtz | grep -q PH2FOFCWT; then
fofc2="F1=2FOFCWT SIG1=SIGF PHI=PH2FOFCWT"
Expand Down Expand Up @@ -85,6 +87,7 @@ eof
gzip "/tmp/$2_$3_2fofc.map"
gzip "/tmp/$2_$3_fofc.map"

rm -f /tmp/$2_$3.pdb

else
$root/fft HKLIN $mtz MAPOUT "/tmp/$2_$3.map" << eof
Expand All @@ -96,10 +99,8 @@ F1=F SIG1=SIGF PHI=PHI W=FOM
end
eof

#$mm MAPIN "/tmp/$2_ep.map.tmp" MAPOUT "/tmp/$2_ep.map" XYZIN "$pdb" << eof
#BORDER 5
#eof

gzip "/tmp/$2_$3.map"

fi

rm -f /tmp/$2_$3.mtz
20 changes: 10 additions & 10 deletions api/src/Downstream/Type/FastEp.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ function results() {
$pdb = $this->_get_attachments("sad_fa.pdb");
if ($pdb) {
if (file_exists($pdb["FILE"])) {
$pdb = file_get_contents($pdb["FILE"]);
$pdb_cont = file_get_contents($pdb["FILE"]);
} elseif (file_exists($pdb['FILE'].'.gz')) {
$pdb = gzdecode(file_get_contents($pdb['FILE'].'.gz'));
} else {
$this->_error('Could not find sad_fa.pdb file');
$pdb_cont = gzdecode(file_get_contents($pdb['FILE'].'.gz'));
}
}

foreach (explode("\n", $pdb) as $l) {
if (isset($pdb_cont)) {
foreach (explode("\n", $pdb_cont) as $l) {
if (strpos($l, 'HETATM') !== false) {
$parts = preg_split('/\s+/', $l);
array_push($ats, array(
Expand All @@ -43,19 +43,19 @@ function results() {
$lst = $this->_get_attachments("sad.lst");
if ($lst) {
if (file_exists($lst['FILE'])) {
$lst = file_get_contents($lst['FILE']);
$lst_cont = file_get_contents($lst['FILE']);
} elseif (file_exists($lst['FILE'].'.gz')) {
$lst = gzdecode(file_get_contents($lst['FILE'].'.gz'));
} else {
$this->_error('Could not find sad.lst file');
$lst_cont = gzdecode(file_get_contents($lst['FILE'].'.gz'));
}
}

if (isset($lst_cont)) {
$p1 = array();
$p2 = array();

$graph_vals = 0;
$gvals = array();
foreach (explode("\n", $lst) as $l) {
foreach (explode("\n", $lst_cont) as $l) {
if (
strpos(
$l,
Expand Down
7 changes: 4 additions & 3 deletions api/src/Page/Download.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,15 +257,16 @@ function _get_file($id, $file)
{
// We don't want to allow unlimited file sizes
ini_set('memory_limit', '512M');
$filesystem = new Filesystem();

$filename = $file['FILEPATH'] . '/' . $file['FILENAME'];

// Do the check first, if no file quit early
if (file_exists($filename)) {
if ($filesystem->exists($filename)) {
$response = new BinaryFileResponse($filename);
$this->set_mime_content($response, $filename, $id);
$response->headers->set("Content-Length", filesize($filename));
} elseif (file_exists($filename.'.gz')) {
} elseif ($filesystem->exists($filename.'.gz')) {
$filename = $filename.'.gz';
if ($this->arg('download') == 1) {
// View log file, so unzip and serve
Expand Down Expand Up @@ -479,7 +480,7 @@ function _streamZipFile($files, $zipName)
if (file_exists($filename)) {
$zip->addFileFromPath(basename($filename), $filename);
} elseif (file_exists($filename.'.gz')) {
$zip->addFileFromPath(basename($filename), $filename.'.gz');
$zip->addFileFromPath(basename($filename).'.gz', $filename.'.gz');
}
}

Expand Down

0 comments on commit 6d98705

Please sign in to comment.