Skip to content

Commit

Permalink
feat: Implement Resources class for managing exter
Browse files Browse the repository at this point in the history
  • Loading branch information
sweep-ai[bot] committed Mar 12, 2024
1 parent bbf22fe commit 4a2b316
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions src/Snps/Resources.php
@@ -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;
}
}

0 comments on commit 4a2b316

Please sign in to comment.