Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Implement Resources class for managing exter
- Loading branch information
1 parent
bbf22fe
commit 4a2b316
Showing
1 changed file
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
namespace Dna\Snps; | ||
|
||
use GuzzleHttp\Client; | ||
|
||
class Resources | ||
{ | ||
private string $baseUrl; | ||
private string $localResourceDir; | ||
private Client $httpClient; | ||
|
||
public function __construct(string $baseUrl, string $localResourceDir) | ||
{ | ||
$this->baseUrl = $baseUrl; | ||
$this->localResourceDir = $localResourceDir; | ||
$this->httpClient = new Client(); | ||
} | ||
|
||
public function downloadResource(string $url, string $destinationPath): void | ||
{ | ||
$response = $this->httpClient->get($url); | ||
file_put_contents($destinationPath, $response->getBody()); | ||
} | ||
|
||
public function loadDataFromFile(string $filePath) | ||
{ | ||
return file_get_contents($filePath); | ||
} | ||
|
||
public function getReferenceSequence(string $id): ReferenceSequence | ||
{ | ||
$filePath = $this->getLocalPathForResource($id); | ||
$sequenceData = $this->loadDataFromFile($filePath); | ||
return new ReferenceSequence($id, $sequenceData); | ||
} | ||
|
||
public function getAssemblyMappingData(string $id) | ||
{ | ||
// Implementation for fetching assembly mapping data | ||
} | ||
|
||
public function getExampleDataset(string $id) | ||
{ | ||
// Implementation for fetching example datasets | ||
} | ||
|
||
private function getLocalPathForResource(string $resourceId): string | ||
{ | ||
return $this->localResourceDir . DIRECTORY_SEPARATOR . $resourceId; | ||
} | ||
} |