Skip to content

Commit

Permalink
Merge pull request #116 from liberu-genealogy/sweep/_de62a
Browse files Browse the repository at this point in the history
Sweep:  (✓ Sandbox Passed)
  • Loading branch information
curtisdelicata committed Mar 12, 2024
2 parents 7923602 + 4a2b316 commit b2c8810
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 15 deletions.
30 changes: 15 additions & 15 deletions src/Snps/ReferenceSequence.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ class ReferenceSequence
{

public function __construct(
private readonly string $ID = "",
private readonly string $url = "",
private readonly string $path = "",
private readonly string $assembly = "",
private readonly string $species = "",
private readonly string $taxonomy = ""
private string $ID = "",
private string $url = "",
private string $path = "",
private string $assembly = "",
private string $species = "",
private string $taxonomy = ""
) {
$this->sequence = [];
$this->md5 = "";
Expand All @@ -37,7 +37,7 @@ public function __toString()
*/
public function getID(): string
{
return $this->_ID;
return $this->ID;
}

/**
Expand All @@ -47,7 +47,7 @@ public function getID(): string
*/
public function getChrom(): string
{
return $this->_ID;
return $this->ID;
}

/**
Expand All @@ -57,7 +57,7 @@ public function getChrom(): string
*/
public function getUrl(): string
{
return $this->_url;
return $this->url;
}

/**
Expand All @@ -67,7 +67,7 @@ public function getUrl(): string
*/
public function getPath(): string
{
return $this->_path;
return $this->path;
}

/**
Expand All @@ -77,7 +77,7 @@ public function getPath(): string
*/
public function getAssembly(): string
{
return $this->_assembly;
return $this->assembly;
}

/**
Expand All @@ -87,7 +87,7 @@ public function getAssembly(): string
*/
public function getBuild(): string
{
return "B" . substr($this->_assembly, -2);
return "B" . substr($this->assembly, -2);
}
/**
* Returns the species of the reference sequence.
Expand All @@ -96,7 +96,7 @@ public function getBuild(): string
*/
public function getSpecies(): string
{
return $this->_species;
return $this->species;
}

/**
Expand All @@ -106,7 +106,7 @@ public function getSpecies(): string
*/
public function getTaxonomy(): string
{
return $this->_taxonomy;
return $this->taxonomy;
}

/**
Expand Down Expand Up @@ -167,7 +167,7 @@ private function loadSequence(): void
{
if (!count($this->sequence)) {
// Decompress and read file
$data = file_get_contents($this->_path);
$data = file_get_contents($this->path);

// check if file is gzipped
if (str_starts_with($data, "\x1f\x8b")) {
Expand Down
52 changes: 52 additions & 0 deletions src/Snps/Resources.php
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;
}
}

0 comments on commit b2c8810

Please sign in to comment.