Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LIMS-1074: Allow accessing zipped files #684

Merged
32 changes: 25 additions & 7 deletions api/scripts/mtz2map.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,24 @@ export CLIBD=$CCP4_MASTER/lib/data
export CCP4_SCR=/tmp
export root=$CCP4_MASTER/bin

if [ -f $1 ]; then
mtz=$1
else
if [ -f $1.gz ]; then
mtz=/tmp/$2_$3.mtz
gunzip -c $1.gz > $mtz
John-Holt-Tessella marked this conversation as resolved.
Show resolved Hide resolved
fi
fi
John-Holt-Tessella marked this conversation as resolved.
Show resolved Hide resolved

if [ -f $4 ]; then
pdb=$4
else
if [ -f $4.gz ]; then
pdb=/tmp/$2_$3.pdb
John-Holt-Tessella marked this conversation as resolved.
Show resolved Hide resolved
gunzip -c $4.gz > $pdb
fi
fi
John-Holt-Tessella marked this conversation as resolved.
Show resolved Hide resolved

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

if [ $3 == 'dimple' ]; then
Expand All @@ -23,7 +41,7 @@ if [ $3 == 'dimple' ]; then
# fofc2="F1=F SIG1=SIGF PHI=PHWT W=FOM"
# fofc="F1=F SIG1=SIGF PHI=PHDELWT W=FOM"

if $root/mtzinfo $1 | grep -q PH2FOFCWT; then
if $root/mtzinfo $mtz | grep -q PH2FOFCWT; then
fofc2="F1=2FOFCWT SIG1=SIGF PHI=PH2FOFCWT"
fofc="F1=F SIG1=SIGF PHI=PHFOFCWT W=FOM"
else
Expand All @@ -37,7 +55,7 @@ fi

# F SIGF FC PHIC FC_ALL PHIC_ALL FWT PHWT DELFWT PHDELWT FOM FC_ALL_LS PHIC_ALL_LS

$root/fft HKLIN $1 MAPOUT "/tmp/$2_$3_2fofc.map.tmp" << eof
$root/fft HKLIN $mtz MAPOUT "/tmp/$2_$3_2fofc.map.tmp" << eof
title $2 2fofc
xyzlim asu
scale F1 1.0
Expand All @@ -46,11 +64,11 @@ $fofc2
end
eof

$root/mapmask MAPIN "/tmp/$2_$3_2fofc.map.tmp" MAPOUT "/tmp/$2_$3_2fofc.map" XYZIN "$4" << eof
$root/mapmask MAPIN "/tmp/$2_$3_2fofc.map.tmp" MAPOUT "/tmp/$2_$3_2fofc.map" XYZIN "$pdb" << eof
BORDER 5
eof

$root/fft HKLIN $1 MAPOUT "/tmp/$2_$3_fofc.map.tmp" << eof
$root/fft HKLIN $mtz MAPOUT "/tmp/$2_$3_fofc.map.tmp" << eof
title $2 fofc
xyzlim asu
scale F1 1.0
Expand All @@ -60,7 +78,7 @@ end
eof


$root/mapmask MAPIN "/tmp/$2_$3_fofc.map.tmp" MAPOUT "/tmp/$2_$3_fofc.map" XYZIN "$4" << eof
$root/mapmask MAPIN "/tmp/$2_$3_fofc.map.tmp" MAPOUT "/tmp/$2_$3_fofc.map" XYZIN "$pdb" << eof
BORDER 5
eof

Expand All @@ -69,7 +87,7 @@ gzip "/tmp/$2_$3_fofc.map"


else
$root/fft HKLIN $1 MAPOUT "/tmp/$2_$3.map" << eof
$root/fft HKLIN $mtz MAPOUT "/tmp/$2_$3.map" << eof
title $2 fofc
xyzlim asu
scale F1 1.0
Expand All @@ -78,7 +96,7 @@ F1=F SIG1=SIGF PHI=PHI W=FOM
end
eof

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

Expand Down
8 changes: 6 additions & 2 deletions api/src/Downstream/BigEPPhasing.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,17 @@ function results() {
}

$image = $this->_get_image();
$dat['IMAGE'] = file_exists($image);
$dat['IMAGE'] = file_exists($image) || file_exists($image.'.gz');

$model = $this->_get_attachments('big_ep_model_ispyb.json');
$dat['HASMODEL'] = $model && file_exists($model['FILE']);
$dat['HASMODEL'] = $model && (file_exists($model['FILE']) || file_exists($model['FILE'].'.gz'));
if ($model) {
if (file_exists($model['FILE'])) {
$json_str = file_get_contents($model['FILE']);
} elseif (file_exists($model['FILE'].'.gz')) {
$json_str = gzdecode(file_get_contents($model['FILE'].'.gz'));
}
if (isset($json_str)) {
$json_data = json_decode($json_str, true);
foreach (
array(
Expand Down
138 changes: 75 additions & 63 deletions api/src/Downstream/Type/FastEp.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,82 +17,94 @@ function results() {
if ($pdb) {
if (file_exists($pdb["FILE"])) {
$pdb = file_get_contents($pdb["FILE"]);
foreach (explode("\n", $pdb) as $l) {
if (strpos($l, 'HETATM') !== false) {
$parts = preg_split('/\s+/', $l);
array_push($ats, array(
$parts[1],
$parts[5],
$parts[6],
$parts[7],
$parts[8],
));
}
}
} elseif (file_exists($pdb['FILE'].'.gz')) {
$pdb = gzdecode(file_get_contents($pdb['FILE'].'.gz'));
} else {
$this->_error('Could not find sad_fa.pdb file');
}

$dat['ATOMS'] = array_slice($ats, 0, 5);
foreach (explode("\n", $pdb) as $l) {
if (strpos($l, 'HETATM') !== false) {
$parts = preg_split('/\s+/', $l);
array_push($ats, array(
$parts[1],
$parts[5],
$parts[6],
$parts[7],
$parts[8],
));
}
}

$dat['ATOMS'] = array_slice($ats, 0, 5);

}

$lst = $this->_get_attachments("sad.lst");
if ($lst) {
if (file_exists($lst['FILE'])) {
$p1 = array();
$p2 = array();

$lst = file_get_contents($lst['FILE']);
$graph_vals = 0;
$gvals = array();
foreach (explode("\n", $lst) as $l) {
if (
strpos(
$l,
'Estimated mean FOM and mapCC as a function of resolution'
) !== false
) {
$graph_vals = 1;
}

if ($graph_vals && $graph_vals < 5) {
array_push($gvals, $l);
$graph_vals++;
}

if (
preg_match(
'/ Estimated mean FOM = (\d+.\d+)\s+Pseudo-free CC = (\d+.\d+)/',
$l,
$mat
)
) {
$dat['FOM'] = floatval($mat[1]);
$dat['CC'] = floatval($mat[2]);
}
} elseif (file_exists($lst['FILE'].'.gz')) {
$lst = gzdecode(file_get_contents($lst['FILE'].'.gz'));
} else {
$this->_error('Could not find sad.lst file');
John-Holt-Tessella marked this conversation as resolved.
Show resolved Hide resolved
}

$p1 = array();
$p2 = array();

$graph_vals = 0;
$gvals = array();
foreach (explode("\n", $lst) as $l) {
if (
strpos(
$l,
'Estimated mean FOM and mapCC as a function of resolution'
) !== false
) {
$graph_vals = 1;
}

if (sizeof($gvals) > 0) {
$x = array_map(
'floatval',
array_slice(explode(' - ', $gvals[1]), 1)
);
$y = array_map(
'floatval',
array_slice(preg_split('/\s+/', $gvals[2]), 2)
);
$y2 = array_map(
'floatval',
array_slice(preg_split('/\s+/', $gvals[3]), 2)
);

foreach ($x as $i => $v) {
array_push($p1, array(1.0 / pow($v, 2), $y[$i]));
array_push($p2, array(1.0 / pow($v, 2), $y2[$i]));
}
if ($graph_vals && $graph_vals < 5) {
array_push($gvals, $l);
$graph_vals++;
}

$dat['PLOTS']['FOM'] = $p1;
$dat['PLOTS']['CC'] = $p2;
if (
preg_match(
'/ Estimated mean FOM = (\d+.\d+)\s+Pseudo-free CC = (\d+.\d+)/',
$l,
$mat
)
) {
$dat['FOM'] = floatval($mat[1]);
$dat['CC'] = floatval($mat[2]);
}
}

if (sizeof($gvals) > 0) {
$x = array_map(
'floatval',
array_slice(explode(' - ', $gvals[1]), 1)
);
$y = array_map(
'floatval',
array_slice(preg_split('/\s+/', $gvals[2]), 2)
);
$y2 = array_map(
'floatval',
array_slice(preg_split('/\s+/', $gvals[3]), 2)
);

foreach ($x as $i => $v) {
array_push($p1, array(1.0 / pow($v, 2), $y[$i]));
array_push($p2, array(1.0 / pow($v, 2), $y2[$i]));
}
}

$dat['PLOTS']['FOM'] = $p1;
$dat['PLOTS']['CC'] = $p2;

}

$results = new DownstreamResult($this);
Expand Down
4 changes: 4 additions & 0 deletions api/src/Page/DC.php
Original file line number Diff line number Diff line change
Expand Up @@ -1605,6 +1605,10 @@ function _rd($aid, $id)
$rows = array();
if (file_exists($file)) {
$log = file_get_contents($file);
} elseif (file_exists($file.'.gz')) {
$log = gzdecode(file_get_contents($file.'.gz'));
}
if (isset($log)) {

$start = 0;
foreach (explode("\n", $log) as $l) {
Expand Down
Loading
Loading