Skip to content

Commit

Permalink
Fix #21
Browse files Browse the repository at this point in the history
  • Loading branch information
JR-1991 committed Feb 22, 2022
1 parent 0ff46e3 commit 2f55916
Show file tree
Hide file tree
Showing 26 changed files with 6,668 additions and 6,723 deletions.
46 changes: 22 additions & 24 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,34 @@

name: Build and Test

on: [push]

jobs:
build:

runs-on: ubuntu-latest
strategy:
max-parallel: 4
matrix:
python-version: [3.9, '3.10']
python-version: ['3.7', '3.8', 3.9', '3.10']

steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python3 -m pip install --upgrade pip
pip3 install python-copasi
pip3 install -e .[test]
- name: Test with pytest
run: |
python3 -m pytest
- name: Lint with flake8
run: |
pip install flake8
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=13 --max-line-length=127 --statistics
- name: Checkout
uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python3 -m pip install --upgrade pip
pip3 install python-copasi
pip3 install -e .[test]
- name: Test with pytest
run: |
python3 -m pytest
- name: Lint with flake8
run: |
pip install flake8
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=13 --max-line-length=127 --statistics
50 changes: 25 additions & 25 deletions pyenzyme/enzymeml/core/__init__.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
'''
File: __init__.py
Project: core
Author: Jan Range
License: BSD-2 clause
-----
Last Modified: Tuesday June 15th 2021 7:32:36 pm
Modified By: Jan Range (<jan.range@simtech.uni-stuttgart.de>)
-----
Copyright (c) 2021 Institute of Biochemistry and Technical Biochemistry Stuttgart
'''

from pyenzyme.enzymeml.core.creator import Creator
from pyenzyme.enzymeml.core.enzymemldocument import EnzymeMLDocument
from pyenzyme.enzymeml.core.protein import Protein
from pyenzyme.enzymeml.core.complex import Complex
from pyenzyme.enzymeml.core.reactant import Reactant
from pyenzyme.enzymeml.core.replicate import Replicate
from pyenzyme.enzymeml.core.unitdef import UnitDef
from pyenzyme.enzymeml.core.vessel import Vessel
from pyenzyme.enzymeml.core.enzymereaction import EnzymeReaction
from pyenzyme.enzymeml.core.enzymemlbase import EnzymeMLBase
from pyenzyme.enzymeml.core.measurementData import MeasurementData
from pyenzyme.enzymeml.core.measurement import Measurement
from pyenzyme.enzymeml.core.ontology import SBOTerm, DataTypes
'''
File: __init__.py
Project: core
Author: Jan Range
License: BSD-2 clause
-----
Last Modified: Tuesday June 15th 2021 7:32:36 pm
Modified By: Jan Range (<jan.range@simtech.uni-stuttgart.de>)
-----
Copyright (c) 2021 Institute of Biochemistry and Technical Biochemistry Stuttgart
'''

from pyenzyme.enzymeml.core.creator import Creator
from pyenzyme.enzymeml.core.enzymemldocument import EnzymeMLDocument
from pyenzyme.enzymeml.core.protein import Protein
from pyenzyme.enzymeml.core.complex import Complex
from pyenzyme.enzymeml.core.reactant import Reactant
from pyenzyme.enzymeml.core.replicate import Replicate
from pyenzyme.enzymeml.core.unitdef import UnitDef
from pyenzyme.enzymeml.core.vessel import Vessel
from pyenzyme.enzymeml.core.enzymereaction import EnzymeReaction
from pyenzyme.enzymeml.core.enzymemlbase import EnzymeMLBase
from pyenzyme.enzymeml.core.measurementData import MeasurementData
from pyenzyme.enzymeml.core.measurement import Measurement
from pyenzyme.enzymeml.core.ontology import SBOTerm, DataTypes
6 changes: 3 additions & 3 deletions pyenzyme/enzymeml/core/complex.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import re

from pydantic import validator, Field
from typing import Optional, TYPE_CHECKING
from typing import List, Optional, TYPE_CHECKING
from dataclasses import dataclass

from pyenzyme.enzymeml.core.enzymemlbase import EnzymeMLBase
Expand All @@ -38,7 +38,7 @@ class Complex(EnzymeMLBase, AbstractSpecies):
description="Name of the complex",
)

participants: list[str] = Field(
participants: List[str] = Field(
default_factory=list,
description="Array of IDs the complex contains",
)
Expand Down Expand Up @@ -108,7 +108,7 @@ def set_meta_id(cls, id: Optional[str], values: dict):
return id

@validator("participants")
def check_reactant_ids(cls, ids: list[str]):
def check_reactant_ids(cls, ids: List[str]):
"""Checks ID consistency for reactants"""

for id in ids:
Expand Down
162 changes: 81 additions & 81 deletions pyenzyme/enzymeml/core/creator.py
Original file line number Diff line number Diff line change
@@ -1,81 +1,81 @@
'''
File: creator.py
Project: core
Author: Jan Range
License: BSD-2 clause
-----
Last Modified: Tuesday June 15th 2021 6:28:16 pm
Modified By: Jan Range (<jan.range@simtech.uni-stuttgart.de>)
-----
Copyright (c) 2021 Institute of Biochemistry and Technical Biochemistry Stuttgart
'''

from pydantic import Field, validator, ValidationError
from typing import TYPE_CHECKING, Optional
from dataclasses import dataclass

from pyenzyme.enzymeml.core.enzymemlbase import EnzymeMLBase
from pyenzyme.enzymeml.core.utils import (
type_checking,
deprecated_getter
)

if TYPE_CHECKING: # pragma: no cover
static_check_init_args = dataclass
else:
static_check_init_args = type_checking


@static_check_init_args
class Creator(EnzymeMLBase):

given_name: str = Field(
...,
description='Given name of the author or contributor.',
)

family_name: str = Field(
...,
description='Family name of the author or contributor.',
)

mail: str = Field(
...,
description='Email address of the author or contributor.',
)

id: Optional[str] = Field(
None,
description="Unique identifier of the protein.",
regex=r"a[\d]+"
)

@validator("given_name", "family_name", "mail", pre=True)
def check_empty_strings(cls, value):
if not value:
raise ValueError(
"An empty string has been provided. Please make sure to provide a valid string."
)

return value

@validator("mail")
def check_mail_consistency(cls, mail):
if len(mail.split("@")) != 2:
raise ValueError(
f"{mail} is not a valid mail adress."
)

return mail

@deprecated_getter("family_name")
def getFname(self) -> str:
return self.family_name

@deprecated_getter("given_name")
def getGname(self) -> str:
return self.given_name

@deprecated_getter("mail")
def getMail(self) -> str:
return self.mail
'''
File: creator.py
Project: core
Author: Jan Range
License: BSD-2 clause
-----
Last Modified: Tuesday June 15th 2021 6:28:16 pm
Modified By: Jan Range (<jan.range@simtech.uni-stuttgart.de>)
-----
Copyright (c) 2021 Institute of Biochemistry and Technical Biochemistry Stuttgart
'''

from pydantic import Field, validator, ValidationError
from typing import TYPE_CHECKING, Optional
from dataclasses import dataclass

from pyenzyme.enzymeml.core.enzymemlbase import EnzymeMLBase
from pyenzyme.enzymeml.core.utils import (
type_checking,
deprecated_getter
)

if TYPE_CHECKING: # pragma: no cover
static_check_init_args = dataclass
else:
static_check_init_args = type_checking


@static_check_init_args
class Creator(EnzymeMLBase):

given_name: str = Field(
...,
description='Given name of the author or contributor.',
)

family_name: str = Field(
...,
description='Family name of the author or contributor.',
)

mail: str = Field(
...,
description='Email address of the author or contributor.',
)

id: Optional[str] = Field(
None,
description="Unique identifier of the protein.",
regex=r"a[\d]+"
)

@validator("given_name", "family_name", "mail", pre=True)
def check_empty_strings(cls, value):
if not value:
raise ValueError(
"An empty string has been provided. Please make sure to provide a valid string."
)

return value

@validator("mail")
def check_mail_consistency(cls, mail):
if len(mail.split("@")) != 2:
raise ValueError(
f"{mail} is not a valid mail adress."
)

return mail

@deprecated_getter("family_name")
def getFname(self) -> str:
return self.family_name

@deprecated_getter("given_name")
def getGname(self) -> str:
return self.given_name

@deprecated_getter("mail")
def getMail(self) -> str:
return self.mail

0 comments on commit 2f55916

Please sign in to comment.