-
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #116 from liberu-genealogy/sweep/_de62a
Sweep: (✓ Sandbox Passed)
- Loading branch information
Showing
2 changed files
with
67 additions
and
15 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
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; | ||
} | ||
} |