コード例 #1
0
ファイル: getXML.php プロジェクト: raffled/Lexomics
// if uploading a tsv indicated by the POST['type']
if ($_POST['type'] == 'tsv' or $_POST['type'] == 'csv' or $_POST['type'] == 'txt') {
    // get clustering parameters
    $method = $_POST['method'];
    $metric = $_POST['metric'];
    $output = 'phyloxml';
    //create an xml file
    $title = $_POST['title'];
    $type = $_POST['type'];
    $p = $_POST['p'];
    # $addLabels = $addLabels;
    # $labelFile = $labelFile;
    // build the argument string for Rscript
    // flags do nothing,
    // future: make flags work, right now, R script assumes current order
    $rArgs = "-f {$infile} -m {$method} -d {$metric} -o {$output} -t \"{$title}\" \n\t-p {$p} -s {$type} -l {$labelFile}";
    // the file name is the expected output of clustr.r
    $stdout = callR("clustr.r", "{$rArgs}");
    $stdout = explode(",<r>,", $stdout);
    $file = $stdout[0];
    $rowlabels = $stdout[1];
    $out = openfile($file, "b");
    //give the file to the user to download
    // $name = $_FILES['file']['name'];
    $name = $title;
    require "download.php";
    // download script
    downloadFile($file, "{$name}.xml");
    // and exit so nothing else is sent back to the browser
    exit;
}
コード例 #2
0
ファイル: run.php プロジェクト: raffled/Lexomics
$pattern = '/[^a-zA-Z0-9]/';
$dataset = preg_replace($pattern, "_", $dataset);
// in the case that the user does not provide an output file name
if ($dataset == '') {
    $dataset = "dist-output";
}
//dist.function.R takes number as argument for distance metric
if ($distance == 'Kruskal-Wallis') {
    $distance = 1;
} else {
    $distance = 2;
}
// string of arguments used by the RSCRIPT
// MUST BE IN THIS ORDER
$rArgs = "{$infile} {$clades} {$levels} {$metric} {$p} {$linkage} {$dataset} {$distance} {$tsv}";
$stdout = callR("callR.r", "{$rArgs}");
// $stdout contains all stdout of R code
// split $stdout at newlines
$stdout = explode("\n", $stdout);
// $stdout is an array. The last thing in the array is the full path
//  of the actual file that we need
$file = $stdout[count($stdout) - 1];
// ** Download the zipped file ******************************
//copy($file, "/tmp/foo.zip" );
if (file_exists($file)) {
    header("Content-type: application/zip");
    header("Content-Disposition: attachment; filename={$dataset}.zip");
    header("Pragma: no-cache");
    header("Expires: 0");
    ob_clean();
    flush();