Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 1.0.2 #152

Merged
merged 37 commits into from
Jun 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
67a9aed
Bump symfony/dotenv from 5.2.4 to 5.3.0
dependabot[bot] Jun 1, 2021
d9b2acf
Bump symfony/phpunit-bridge from 5.2.9 to 5.3.0
dependabot[bot] Jun 1, 2021
c3c0303
Merge pull request #141 from privrja/dependabot/composer/devel/symfon…
privrja Jun 3, 2021
63f250a
Merge pull request #143 from privrja/dependabot/composer/devel/symfon…
privrja Jun 3, 2021
9153021
Bump symfony/console from 5.2.8 to 5.3.0
dependabot[bot] Jun 3, 2021
e928dfa
Merge pull request #139 from privrja/dependabot/composer/devel/symfon…
privrja Jun 3, 2021
a2d97fa
Bump symfony/asset from 5.2.7 to 5.2.10
dependabot[bot] Jun 3, 2021
40b8a32
Bump symfony/expression-language from 5.2.7 to 5.3.0
dependabot[bot] Jun 3, 2021
590f7d2
Merge pull request #145 from privrja/dependabot/composer/devel/symfon…
privrja Jun 3, 2021
bcc0492
Merge pull request #144 from privrja/dependabot/composer/devel/symfon…
privrja Jun 3, 2021
d1000b6
Bump symfony/yaml from 5.2.9 to 5.3.0
dependabot[bot] Jun 3, 2021
d59ff46
Merge pull request #148 from privrja/dependabot/composer/devel/symfon…
privrja Jun 3, 2021
ab88748
Bump nelmio/api-doc-bundle from 4.2.0 to 4.3.0
dependabot[bot] Jun 8, 2021
1dd68a3
Merge pull request #149 from privrja/dependabot/composer/devel/nelmio…
privrja Jun 8, 2021
4312f6b
Bump symfony/asset from 5.2.10 to 5.3.0
dependabot[bot] Jun 9, 2021
e3fae9b
Merge pull request #150 from privrja/dependabot/composer/devel/symfon…
privrja Jun 9, 2021
ca47211
Bump sensio/framework-extra-bundle from 6.1.4 to 6.1.5
dependabot[bot] Jun 9, 2021
523598a
Bump symfony/security-bundle from 5.2.9 to 5.3.0
dependabot[bot] Jun 9, 2021
abd99a1
Merge pull request #147 from privrja/dependabot/composer/devel/sensio…
privrja Jun 9, 2021
f006f75
Merge pull request #142 from privrja/dependabot/composer/devel/symfon…
privrja Jun 9, 2021
861dbea
Bump symfony/framework-bundle from 5.2.10 to 5.3.0
dependabot[bot] Jun 10, 2021
42e88aa
Fix acronym unique violation
privrja Jun 12, 2021
0785108
Merge remote-tracking branch 'origin/devel' into devel
privrja Jun 12, 2021
0e1be2b
Merge pull request #151 from privrja/dependabot/composer/devel/symfon…
privrja Jun 12, 2021
dc9da63
Fix similarity using name
privrja Jun 12, 2021
505b2d6
Merge remote-tracking branch 'origin/devel' into devel
privrja Jun 12, 2021
0cb2929
Add COCONUT server
privrja Jun 12, 2021
3f6f461
Add servers
privrja Jun 12, 2021
a7eaaab
Fix import sequence
privrja Jun 12, 2021
6d2a41d
Refactoring
privrja Jun 12, 2021
4f5af7b
Fix export
privrja Jun 13, 2021
32dca77
Add NPAtlas
privrja Jun 13, 2021
ab19040
Chebi export fix
privrja Jun 13, 2021
6870899
Refactoring
privrja Jun 13, 2021
e7ea95b
Change doc address
privrja Jun 13, 2021
7b42f21
Update README.md
privrja Jun 13, 2021
9699760
Update README.md
privrja Jun 13, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ To drop DB and create new use:

```php bin/console doctrine:mig:mig```

```php bin/console doctrine:fixtures:load```
```php bin/console doctrine:fixtures:load --group=prod``` or dev group

### Run tests
Before every test you need to delete, create, migrate and purge DB like in previuos step, now test can't be run more times in a row.
Expand All @@ -33,5 +33,5 @@ To run test use ```composer test``` or ```php ./vendor/symfony/phpunit-bridge/bi

```symfony server:start```

Documentation of API is [localhost:8000/api/doc](https://localhost:8000/api/doc)
Documentation of API is [localhost:8000/rest/doc](https://localhost:8000/rest/doc)
Rest API is on [localhost:8000/rest](https://localhost:8000/rest)
14 changes: 7 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@
"netresearch/jsonmapper": "^4.0",
"sensio/framework-extra-bundle": "^6.0",
"symfony/apache-pack": "^1.0",
"symfony/asset": "5.2.*",
"symfony/console": "5.2.*",
"symfony/dotenv": "5.2.*",
"symfony/expression-language": "5.2.*",
"symfony/asset": "5.3.*",
"symfony/console": "5.3.*",
"symfony/dotenv": "5.3.*",
"symfony/expression-language": "5.3.*",
"symfony/flex": "^1.3.1",
"symfony/framework-bundle": "5.2.*",
"symfony/framework-bundle": "5.3.*",
"symfony/monolog-bundle": "^3.5",
"symfony/orm-pack": "^2.0",
"symfony/security-bundle": "5.2.*",
"symfony/security-bundle": "5.3.*",
"symfony/twig-pack": "^1.0",
"symfony/yaml": "5.2.*"
"symfony/yaml": "5.3.*"
},
"require-dev": {
"symfony/maker-bundle": "^1.14",
Expand Down
799 changes: 511 additions & 288 deletions composer.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion config/packages/nelmio_api_doc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ nelmio_api_doc:
in: header
areas: # to filter documented areas
path_patterns:
- ^/rest
- ^/rest(?!/doc.*$)
4 changes: 2 additions & 2 deletions config/routes/nelmio_api_doc.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Expose your documentation as JSON swagger compliant
app.swagger:
path: /api/doc.json
path: /rest/doc.json
methods: GET
defaults: { _controller: nelmio_api_doc.controller.swagger }

## Requires the Asset component and the Twig bundle
## $ composer require twig asset
app.swagger_ui:
path: /api/doc
path: /rest/doc
methods: GET
defaults: { _controller: nelmio_api_doc.controller.swagger_ui }
15 changes: 14 additions & 1 deletion src/Base/ReferenceHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
class ReferenceHelper {

const SMILES = "SMILES: ";
const CHEBI = 'CHEBI: ';

public static function reference($database, $reference, $smiles) {
if ($reference == 0) {
if (!isset($reference) || $reference === '') {
return self::defaultValue($smiles);
}
switch ($database) {
Expand All @@ -24,7 +25,19 @@ public static function reference($database, $reference, $smiles) {
case ServerEnum::PDB:
return ServerEnum::$cycloBranchValues[ServerEnum::PDB] . $reference;
case ServerEnum::NORINE:
case ServerEnum::COCONUT:
case ServerEnum::NP_ATLAS:
return $reference;
case ServerEnum::CHEBI:
if (str_contains($reference, 'CHEBI:')) {
if (str_contains($reference, self::CHEBI)) {
return strtoupper($reference);
} else {
return self::CHEBI . substr($reference, 6);
}
} else {
return self::CHEBI . $reference;
}
case ServerEnum::SIDEROPHORE_BASE:
return ServerEnum::$cycloBranchValues[ServerEnum::SIDEROPHORE_BASE] . $reference;
case ServerEnum::DOI:
Expand Down
2 changes: 2 additions & 0 deletions src/Base/SequenceHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ function findBlocks(Container $container, BlockRepository $blockRepository): arr
if (!isset($block)) {
return [];
}
$b2s->setBlockOriginalId($len);
$b2s->setSort($len);
$b2s->setBlock($block);
$b2s->setIsBranch($this->branch);
$branchNextAcronym = $this->branchNext(true);
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/SmilesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public function similarityContainer(Container $container, Request $request, Logg
}
$setup = $setupRepository->findOneBy(['id' => 1]);
if ($setup->getSimilarity() === 'name') {
return new JsonResponse($sequenceFamilyRepository->similarity(1, $trans->sequenceName));
return new JsonResponse($sequenceFamilyRepository->similarity($container->getId(), $trans->sequenceName));
} else {
if ($trans->blockLengthUnique === 0) {
return ResponseHelper::jsonResponse(new Message(ErrorConstants::ERROR_EMPTY_PARAMS, Response::HTTP_BAD_REQUEST));
Expand Down
20 changes: 3 additions & 17 deletions src/Enum/ServerEnum.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,8 @@ class ServerEnum {
const DOI = 6;
const SIDEROPHORE_BASE = 7;
const LIPID_MAPS = 8;

/** @var array mapping int code to string */
public static $values = [
self::PUBCHEM => "PubChem",
self::CHEMSPIDER => "ChemSpider",
self::NORINE => "Norine",
self::PDB => "PDB",
self::CHEBI => "ChEBI",
];

public static $backValues = [
'CID: ' => self::PUBCHEM,
'CSID: ' => self::CHEMSPIDER,
':' => self::NORINE,
'PDB: ' => self::PDB,
];
const COCONUT = 9;
const NP_ATLAS = 10;

/** @var array mapping int code to CycloBranch format string */
public static $cycloBranchValues = [
Expand All @@ -42,7 +28,7 @@ class ServerEnum {
];

public static function isOneOf(int $source): bool {
return $source >= self::PUBCHEM && $source <= self::LIPID_MAPS;
return $source >= self::PUBCHEM && $source <= self::NP_ATLAS;
}

}
8 changes: 6 additions & 2 deletions src/Model/ContainerModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,12 @@ private function updateBlockProperties(Container $container, BlockTransformed $t
$acronym = $block->getAcronym();
$this->entityManager->beginTransaction();
$block = $this->setupBlock($container, $block, $trans);
$this->entityManager->persist($block);
$this->entityManager->flush();
try {
$this->entityManager->persist($block);
$this->entityManager->flush();
} catch (UniqueConstraintViolationException $exception) {
return new Message('Block with this acronym is already in container');
}
if ($acronym !== $trans->getAcronym()) {
$blockUsages = $this->blockRepository->blockUsage($block->getContainer()->getId(), $block->getId(), []);
foreach ($blockUsages as $usage) {
Expand Down
19 changes: 13 additions & 6 deletions src/Repository/BlockRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,25 +99,32 @@ function findMergeByFormula(int $containerId) {
$conn = $this->getEntityManager()->getConnection();
$sql = '
select
group_concat(distinct src.block_name order by src.block_name separator \'/\') as block_name,
group_concat(distinct src.acronym order by src.block_name separator \'/\') as acronym,
group_concat(src.block_name order by src.block_name separator \'/\') as block_name, --
group_concat(src.acronym order by src.block_name separator \'/\') as acronym, --
src.residue,
coalesce(src.block_mass, \'\') as block_mass,
group_concat(distinct coalesce(src.losses, \'\') order by src.block_name separator \'/\') as losses,
group_concat(distinct
group_concat(distinct coalesce(src.losses, \'\') order by src.block_name separator \'/\') as losses, --
group_concat( --
case when src.source is not null then
concat(case
when src.source = 0 then \'CID: \'
when src.source = 1 then \'CSID: \'
when src.source = 2 then \'\'
when src.source = 3 then \'PDB: \'
when src.source = 4 then \'\'
when src.source = 6 then \'DOI: \'
when src.source = 7 then \'SB: \'
when src.source = 8 then \'\'
when src.source = 9 then \'\'
when src.source = 10 then \'\'
else \'SMILES: \'
end, case when src.source > 3 then src.usmiles else src.identifier end)
end, case when src.source > 10 or src.source = 5 then src.usmiles else src.identifier end)
else \'\' end
order by src.block_name separator \'/\') as ref
from msb_block src
where src.container_id = :containerId
group by src.residue, src.block_mass';
group by src.residue, src.block_mass;
';
$stmt = $conn->prepare($sql);
$stmt->execute(['containerId' => $containerId]);
return $stmt->fetchAll();
Expand Down
14 changes: 10 additions & 4 deletions src/Repository/SequenceFamilyRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,16 @@ public function __construct(ManagerRegistry $registry) {
public function similarity(int $containerId, string $sequenceName) {
$conn = $this->getEntityManager()->getConnection();
$sql = '
select fam.id as value, fam.sequence_family_name as label
from msb_sequence_family fam
where :sequenceName like concat(\'%\', fam.sequence_family_name, \'%\')
and container_id = :containerId
select fam.id as value, fam.sequence_family_name as label
from (
select seq.id, row_number() over (order by abs(length(:sequenceName) - length(seq.sequence_name)) asc) as RN
from msb_sequence seq
where lower(substring_index(:sequenceName, \' \', 1)) like concat(\'%\', lower(substring_index(seq.sequence_name, \' \', 1)), \'%\')
and seq.container_id = :containerId
) seq
left join msb_s2f s2f on s2f.sequence_id = seq.id
left join msb_sequence_family fam on fam.id = s2f.family_id
where seq.RN = 1;
';
$stmt = $conn->prepare($sql);
$stmt->execute(['sequenceName' => $sequenceName, 'containerId' => $containerId]);
Expand Down