Skip to content
Snippets Groups Projects
Commit 3a033232 authored by Gael Yvert's avatar Gael Yvert
Browse files

plasmid maps now stored in tmp dirs with id as their name (issue #96)

parent 95ef0348
Branches
Tags
1 merge request!1Cirdna
...@@ -247,7 +247,7 @@ class PlasmidBaseController extends BaseController ...@@ -247,7 +247,7 @@ class PlasmidBaseController extends BaseController
$plasmidmap_imgurl=NULL; //todo: put a default image telling that there is no seq $plasmidmap_imgurl=NULL; //todo: put a default image telling that there is no seq
} else { } else {
// draw the map and store its address // draw the map and store its address
$plasmidmap_imgurl=seq2png($seq); $plasmidmap_imgurl=drawplasmidmap($seq, $id);
} }
// prepare to return the view // prepare to return the view
......
...@@ -74,14 +74,20 @@ function blast2cirdna($infile, $outfile, $start, $end){ ...@@ -74,14 +74,20 @@ function blast2cirdna($infile, $outfile, $start, $end){
} }
function seq2png($seq){ function drawplasmidmap($seq, $id){
// ------------------------- // -------------------------
// blast it on dna-features // blast it on dna-features
// ------------------------- // -------------------------
// create a tmp dir with a random name // create a tmp dir with name the plasmid id
$tmpdir = 'storage/tmp/' . sha1( microtime() ) . '/'; $tmpdir = 'storage/tmp/plasmidmaps/' . $id . '/';
system(mkdir($tmpdir)); $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'; $blastdb = 'storage/blast/dnafeatures';
$blastoutfile = $tmpdir . 'blastout.tab'; $blastoutfile = $tmpdir . 'blastout.tab';
...@@ -95,7 +101,7 @@ function seq2png($seq){ ...@@ -95,7 +101,7 @@ function seq2png($seq){
$cmd_blast = "blastn -query ". $qryfasta . " -db ". $blastdb . " -out ". $blastoutfile . " -outfmt 6"; $cmd_blast = "blastn -query ". $qryfasta . " -db ". $blastdb . " -out ". $blastoutfile . " -outfmt 6";
system($cmd_blast, $retval1); system($cmd_blast, $retval1);
if ($retval1 != 0){ if ($retval1 != 0){
return "Error in seq2png() when running " . $cmd_blast; return "Error in drawplasmidmap() when running " . $cmd_blast;
exit; exit;
} }
...@@ -115,14 +121,14 @@ function seq2png($seq){ ...@@ -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"; $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); system($cmd_cirdna, $retval2);
if ($retval2 != 0){ if ($retval2 != 0){
return "Error in seq2png() when running " . $cmd_cirdna; return "Error in drawplasmidmap() when running " . $cmd_cirdna;
exit; exit;
} }
// convert it to svg format // convert it to svg format
$cmd_convert2svg = "pdf2svg " . $cirdnaoutfile . ".pdf " . $cirdnaoutfile . ".svg"; $cmd_convert2svg = "pdf2svg " . $cirdnaoutfile . ".pdf " . $cirdnaoutfile . ".svg";
system($cmd_convert2svg, $retval3); system($cmd_convert2svg, $retval3);
if ($retval3 != 0){ if ($retval3 != 0){
return "Error in seq2png() when running " . $cmd_convert2svg; return "Error in drawplasmidmap() when running " . $cmd_convert2svg;
exit; exit;
} }
......
*
!.gitignore
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment