From 3a033232d30cfd4e7f87a85f2c4fb72f37f594db Mon Sep 17 00:00:00 2001 From: Gael Yvert <Gael.Yvert@ens-lyon.fr> Date: Mon, 19 Apr 2021 11:14:34 +0200 Subject: [PATCH] plasmid maps now stored in tmp dirs with id as their name (issue #96) --- .../Controllers/PlasmidBaseController.php | 2 +- app/Http/Controllers/lib/Seq.php | 20 ++++++++++++------- storage/app/public/tmp/.gitignore | 3 --- 3 files changed, 14 insertions(+), 11 deletions(-) delete mode 100644 storage/app/public/tmp/.gitignore diff --git a/app/Http/Controllers/PlasmidBaseController.php b/app/Http/Controllers/PlasmidBaseController.php index ee8ceb4..1f81155 100755 --- a/app/Http/Controllers/PlasmidBaseController.php +++ b/app/Http/Controllers/PlasmidBaseController.php @@ -247,7 +247,7 @@ class PlasmidBaseController extends BaseController $plasmidmap_imgurl=NULL; //todo: put a default image telling that there is no seq } else { // draw the map and store its address - $plasmidmap_imgurl=seq2png($seq); + $plasmidmap_imgurl=drawplasmidmap($seq, $id); } // prepare to return the view diff --git a/app/Http/Controllers/lib/Seq.php b/app/Http/Controllers/lib/Seq.php index baf1b50..f7055ed 100755 --- a/app/Http/Controllers/lib/Seq.php +++ b/app/Http/Controllers/lib/Seq.php @@ -74,14 +74,20 @@ function blast2cirdna($infile, $outfile, $start, $end){ } -function seq2png($seq){ +function drawplasmidmap($seq, $id){ // ------------------------- // blast it on dna-features // ------------------------- - // create a tmp dir with a random name - $tmpdir = 'storage/tmp/' . sha1( microtime() ) . '/'; - system(mkdir($tmpdir)); + // create a tmp dir with name the plasmid id + $tmpdir = 'storage/tmp/plasmidmaps/' . $id . '/'; + $cmd_mktmpdir = 'mkdir -p ' . $tmpdir; + system($cmd_mktmpdir, $retval0); + if ($retval0 != 0){ + return "Error in drawplasmidmap() when running " . $cmd_mktmpdir; + exit; + } + $blastdb = 'storage/blast/dnafeatures'; $blastoutfile = $tmpdir . 'blastout.tab'; @@ -95,7 +101,7 @@ function seq2png($seq){ $cmd_blast = "blastn -query ". $qryfasta . " -db ". $blastdb . " -out ". $blastoutfile . " -outfmt 6"; system($cmd_blast, $retval1); if ($retval1 != 0){ - return "Error in seq2png() when running " . $cmd_blast; + return "Error in drawplasmidmap() when running " . $cmd_blast; exit; } @@ -115,14 +121,14 @@ function seq2png($seq){ $cmd_cirdna = "cirdna -posblocks Out -posticks Out -blocktype Outline -blockheight 2.5 -postext 1 -textheight 2 -textlength 3.2 -intercolour 7 -graphout pdf -ruler Y -gtitle ' ' -infile ". $cirdnainfile . " -goutfile " . $cirdnaoutfile . " >/dev/null"; system($cmd_cirdna, $retval2); if ($retval2 != 0){ - return "Error in seq2png() when running " . $cmd_cirdna; + return "Error in drawplasmidmap() when running " . $cmd_cirdna; exit; } // convert it to svg format $cmd_convert2svg = "pdf2svg " . $cirdnaoutfile . ".pdf " . $cirdnaoutfile . ".svg"; system($cmd_convert2svg, $retval3); if ($retval3 != 0){ - return "Error in seq2png() when running " . $cmd_convert2svg; + return "Error in drawplasmidmap() when running " . $cmd_convert2svg; exit; } diff --git a/storage/app/public/tmp/.gitignore b/storage/app/public/tmp/.gitignore deleted file mode 100644 index a5baada..0000000 --- a/storage/app/public/tmp/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -* -!.gitignore - -- GitLab