Ejemplo n.º 1
0
 function run()
 {
     $dataset_description = '';
     $ldir = parent::GetParameterValue('indir');
     $odir = parent::GetParameterValue('outdir');
     //download
     if ($this->GetParameterValue('download') == true) {
         $list = $this->getFtpFileList('ftp.ncbi.nih.gov');
         $total = count($list);
         $counter = 1;
         foreach ($list as $f) {
             echo "downloading file {$counter} out of {$total} :" . parent::getParameterValue('download_url') . $f . "... " . PHP_EOL;
             file_put_contents($ldir . $f, file_get_contents(parent::GetParameterValue('download_url') . $f));
             $counter++;
         }
     }
     //if download
     //iterate over the files
     $paths = $this->getFilePaths($ldir, 'gz');
     $lfile = null;
     foreach ($paths as $aPath) {
         $lfile = $aPath;
         $ofile = $odir . basename($aPath, ".gz") . "." . parent::getParameterValue('output_format');
         $gz = false;
         if (strstr(parent::getParameterValue('output_format'), "gz")) {
             $gz = true;
         }
         parent::setWriteFile($ofile, $gz);
         parent::setReadFile($ldir . $lfile, true);
         $source_file = (new DataResource($this))->setURI(parent::getParameterValue('download_url') . basename($aPath))->setTitle('NCBI UniSTS filename: ' . basename($aPath))->setRetrievedDate(date("Y-m-d\\TG:i:s\\Z", filemtime($ldir . $lfile)))->setFormat('xml/unists-format')->setFormat('application/zip')->setPublisher('https://www.ncbi.nlm.nih.gov')->setHomepage('https://www.ncbi.nlm.nih.gov/unists')->setRights('use')->setRights('attribution')->setLicense('https://www.nlm.nih.gov/copyright.html')->setDataset(parent::getDatasetURI());
         $prefix = parent::getPrefix();
         $bVersion = parent::getParameterValue('bio2rdf_release');
         $date = date("Y-m-d\\TG:i:s\\Z");
         $output_file = (new DataResource($this))->setURI("http://download.bio2rdf.org/release/{$bVersion}/{$prefix}")->setTitle("Bio2RDF v{$bVersion} RDF version of {$prefix} (generated at {$date})")->setSource($source_file->getURI())->setCreator("https://github.com/bio2rdf/bio2rdf-scripts/blob/master/unists/unists.php")->setCreateDate($date)->setHomepage("http://download.bio2rdf.org/release/{$bVersion}/{$prefix}/{$prefix}.html")->setPublisher("http://bio2rdf.org")->setRights("use-share-modify")->setRights("restricted-by-source-license")->setLicense("http://creativecommons/licenses/by/3.0/")->setDataset(parent::getDatasetURI());
         $dataset_description .= $output_file->toRDF() . $source_file->toRDF();
         echo "processing {$aPath} ...";
         $this->process();
         echo "done!" . PHP_EOL;
         $this->setWriteFile($odir . $this->getBio2RDFReleaseFile());
         $this->getWriteFile()->write($dataset_description);
         $this->getWriteFile()->close();
     }
     //foreach
 }