Skip to content

Commit

Permalink
Merge pull request #174 from NPLinker/add_init_to_module
Browse files Browse the repository at this point in the history
Add or update `__init__.py`
  • Loading branch information
CunliangGeng authored Oct 31, 2023
2 parents 6301b28 + 305a8a6 commit 8b8723e
Show file tree
Hide file tree
Showing 34 changed files with 90 additions and 65 deletions.
4 changes: 2 additions & 2 deletions src/nplinker/annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
import csv
import os
from deprecated import deprecated
from nplinker.metabolomics.spectrum import GNPS_KEY
from nplinker.metabolomics.spectrum import Spectrum
from nplinker.metabolomics import GNPS_KEY
from nplinker.metabolomics import Spectrum
from .logconfig import LogConfig


Expand Down
5 changes: 5 additions & 0 deletions src/nplinker/metabolomics/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import logging
from .molecular_family import MolecularFamily
from .singleton_family import SingletonFamily
from .spectrum import GNPS_KEY
from .spectrum import Spectrum


logging.getLogger(__name__).addHandler(logging.NullHandler())

__all__ = ['MolecularFamily', 'SingletonFamily', 'GNPS_KEY', 'Spectrum']
4 changes: 2 additions & 2 deletions src/nplinker/metabolomics/abc.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from abc import ABC
from abc import abstractmethod
from collections.abc import Sequence
from nplinker.metabolomics.molecular_family import MolecularFamily
from nplinker.metabolomics.spectrum import Spectrum
from nplinker.metabolomics import MolecularFamily
from nplinker.metabolomics import Spectrum


class SpectrumLoaderBase(ABC):
Expand Down
21 changes: 21 additions & 0 deletions src/nplinker/metabolomics/gnps/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import logging
from .gnps_annotation_loader import GNPSAnnotationLoader
from .gnps_downloader import GNPSDownloader
from .gnps_extractor import GNPSExtractor
from .gnps_file_mapping_loader import GNPSFileMappingLoader
from .gnps_format import gnps_format_from_archive
from .gnps_format import gnps_format_from_file_mapping
from .gnps_format import gnps_format_from_task_id
from .gnps_format import GNPSFormat
from .gnps_molecular_family_loader import GNPSMolecularFamilyLoader
from .gnps_spectrum_loader import GNPSSpectrumLoader


logging.getLogger(__name__).addHandler(logging.NullHandler())

__all__ = [
"GNPSAnnotationLoader", "GNPSDownloader", "GNPSExtractor",
"GNPSFileMappingLoader", "GNPSFormat", "GNPSMolecularFamilyLoader",
"GNPSSpectrumLoader", "gnps_format_from_archive",
"gnps_format_from_file_mapping", "gnps_format_from_task_id"
]
4 changes: 2 additions & 2 deletions src/nplinker/metabolomics/gnps/gnps_downloader.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from os import PathLike
from pathlib import Path
from typing_extensions import Self
from nplinker.metabolomics.gnps.gnps_format import gnps_format_from_task_id
from nplinker.metabolomics.gnps.gnps_format import GNPSFormat
from nplinker.utils import download_url
from .gnps_format import gnps_format_from_task_id
from .gnps_format import GNPSFormat


class GNPSDownloader:
Expand Down
4 changes: 2 additions & 2 deletions src/nplinker/metabolomics/gnps/gnps_extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
from pathlib import Path
import zipfile
from nplinker import utils
from nplinker.metabolomics.gnps.gnps_format import gnps_format_from_archive
from nplinker.metabolomics.gnps.gnps_format import GNPSFormat
from .gnps_format import gnps_format_from_archive
from .gnps_format import GNPSFormat


class GNPSExtractor:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import csv
from os import PathLike
from nplinker.metabolomics import MolecularFamily
from nplinker.metabolomics import SingletonFamily
from nplinker.metabolomics.abc import MolecularFamilyLoaderBase
from nplinker.metabolomics.molecular_family import MolecularFamily
from nplinker.metabolomics.singleton_family import SingletonFamily
from nplinker.utils import is_file_format


Expand Down
2 changes: 1 addition & 1 deletion src/nplinker/metabolomics/gnps/gnps_spectrum_loader.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from os import PathLike
from pyteomics import mgf
from nplinker.logconfig import LogConfig
from nplinker.metabolomics import Spectrum
from nplinker.metabolomics.abc import SpectrumLoaderBase
from nplinker.metabolomics.spectrum import Spectrum


logger = LogConfig.getLogger(__name__)
Expand Down
6 changes: 3 additions & 3 deletions src/nplinker/metabolomics/load_gnps.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
from typing import Any
from deprecated import deprecated
from nplinker.logconfig import LogConfig
from nplinker.metabolomics.gnps.gnps_format import gnps_format_from_file_mapping
from nplinker.metabolomics.gnps.gnps_format import GNPSFormat
from nplinker.metabolomics.spectrum import Spectrum
from nplinker.metabolomics import Spectrum
from nplinker.metabolomics.gnps import gnps_format_from_file_mapping
from nplinker.metabolomics.gnps import GNPSFormat
from nplinker.strain_collection import StrainCollection
from nplinker.strains import Strain

Expand Down
7 changes: 5 additions & 2 deletions src/nplinker/metabolomics/molecular_family.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
from typing_extensions import Self
from nplinker.metabolomics.spectrum import Spectrum
from __future__ import annotations
from typing import TYPE_CHECKING
from nplinker.strain_collection import StrainCollection
from nplinker.strains import Strain


if TYPE_CHECKING:
from .spectrum import Spectrum

class MolecularFamily():

def __init__(self, family_id: str):
Expand Down
4 changes: 2 additions & 2 deletions src/nplinker/nplinker.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
from .loader import DatasetLoader
from .loader import NPLINKER_APP_DATA_DIR
from .logconfig import LogConfig
from .metabolomics.molecular_family import MolecularFamily
from .metabolomics.spectrum import Spectrum
from .metabolomics import MolecularFamily
from .metabolomics import Spectrum
from .pickler import save_pickled_data
from .scoring.link_collection import LinkCollection
from .scoring.metcalf_scoring import MetcalfScoring
Expand Down
4 changes: 2 additions & 2 deletions src/nplinker/pairedomics/downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
from nplinker.genomics.mibig import download_and_extract_mibig_metadata
from nplinker.globals import PFAM_PATH
from nplinker.logconfig import LogConfig
from nplinker.metabolomics.gnps.gnps_downloader import GNPSDownloader
from nplinker.metabolomics.gnps.gnps_extractor import GNPSExtractor
from nplinker.metabolomics.gnps import GNPSDownloader
from nplinker.metabolomics.gnps import GNPSExtractor
from nplinker.utils import download_url
from . import podp_download_and_extract_antismash_data
from .runbigscape import podp_run_bigscape
Expand Down
3 changes: 1 addition & 2 deletions src/nplinker/pairedomics/strain_mappings_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
from os import PathLike
from pathlib import Path
from jsonschema import validate
from nplinker.metabolomics.gnps.gnps_file_mapping_loader import \
GNPSFileMappingLoader
from nplinker.metabolomics.gnps import GNPSFileMappingLoader
from nplinker.schemas import GENOME_BGC_MAPPINGS_SCHEMA
from nplinker.schemas import validate_podp_json
from nplinker.strain_collection import StrainCollection
Expand Down
4 changes: 2 additions & 2 deletions src/nplinker/pickler.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
from .genomics import BGC
from .genomics import GCF
from .logconfig import LogConfig
from .metabolomics.molecular_family import MolecularFamily
from .metabolomics.spectrum import Spectrum
from .metabolomics import MolecularFamily
from .metabolomics import Spectrum


logger = LogConfig.getLogger(__name__)
Expand Down
6 changes: 3 additions & 3 deletions src/nplinker/scoring/linking/data_links.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import pandas as pd
from nplinker.genomics.gcf import GCF
from nplinker.logconfig import LogConfig
from nplinker.metabolomics.molecular_family import MolecularFamily
from nplinker.metabolomics.singleton_family import SingletonFamily
from nplinker.metabolomics.spectrum import Spectrum
from nplinker.metabolomics import MolecularFamily
from nplinker.metabolomics import SingletonFamily
from nplinker.metabolomics import Spectrum
from .utils import calc_correlation_matrix
from .utils import isinstance_all

Expand Down
4 changes: 2 additions & 2 deletions src/nplinker/scoring/linking/link_finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
from scipy.stats import hypergeom
from nplinker.genomics.gcf import GCF
from nplinker.logconfig import LogConfig
from nplinker.metabolomics.molecular_family import MolecularFamily
from nplinker.metabolomics.spectrum import Spectrum
from nplinker.metabolomics import MolecularFamily
from nplinker.metabolomics import Spectrum
from . import LINK_TYPES
from .utils import isinstance_all

Expand Down
10 changes: 5 additions & 5 deletions src/nplinker/scoring/metcalf_scoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@
import pandas as pd
from nplinker.genomics import GCF
from nplinker.logconfig import LogConfig
from nplinker.metabolomics.molecular_family import MolecularFamily
from nplinker.metabolomics.spectrum import Spectrum
from nplinker.metabolomics import MolecularFamily
from nplinker.metabolomics import Spectrum
from nplinker.pickler import load_pickled_data
from nplinker.pickler import save_pickled_data
from .linking import LINK_TYPES
from .linking import DataLinks
from .linking import LinkFinder
from .linking import isinstance_all
from .linking import LINK_TYPES
from .linking import LinkFinder
from .methods import ScoringMethod
from .object_link import ObjectLink


if TYPE_CHECKING:
from ..nplinker import NPLinker
from . import LinkCollection
from ..nplinker import NPLinker

logger = LogConfig.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion src/nplinker/scoring/np_class_scoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from nplinker.genomics import BGC
from nplinker.genomics import GCF
from nplinker.logconfig import LogConfig
from nplinker.metabolomics.spectrum import Spectrum
from nplinker.metabolomics import Spectrum
from nplinker.scoring.metcalf_scoring import MetcalfScoring
from nplinker.scoring.methods import ScoringMethod
from nplinker.scoring.object_link import ObjectLink
Expand Down
2 changes: 1 addition & 1 deletion src/nplinker/scoring/rosetta/spec_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.

from sortedcontainers import SortedList
from nplinker.metabolomics.gnps.gnps_spectrum_loader import GNPSSpectrumLoader
from nplinker.metabolomics.gnps import GNPSSpectrumLoader
from ...logconfig import LogConfig
from .rosetta_functions import fast_cosine

Expand Down
2 changes: 1 addition & 1 deletion src/nplinker/scoring/rosetta_scoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from nplinker.genomics.bgc import BGC
from nplinker.genomics.gcf import GCF
from nplinker.logconfig import LogConfig
from nplinker.metabolomics.molecular_family import MolecularFamily
from nplinker.metabolomics import MolecularFamily
from nplinker.scoring.methods import ScoringMethod
from nplinker.scoring.object_link import ObjectLink
from nplinker.scoring.rosetta.rosetta import Rosetta
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import shutil
import pytest
from nplinker.globals import STRAIN_MAPPINGS_FILENAME
from nplinker.metabolomics import Spectrum
from nplinker.metabolomics.metabolomics import load_spectra
from nplinker.metabolomics.spectrum import Spectrum
from nplinker.strain_collection import StrainCollection
from nplinker.strains import Strain
from . import DATA_DIR
Expand Down
2 changes: 1 addition & 1 deletion tests/metabolomics/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import shutil
import httpx
import pytest
from nplinker.metabolomics.gnps.gnps_format import GNPSFormat
from nplinker.metabolomics.gnps import GNPSFormat
from nplinker.utils import extract_archive
from .. import GNPS_DATA_DIR

Expand Down
5 changes: 2 additions & 3 deletions tests/metabolomics/test_gnps_annotation_loader.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import pytest
from nplinker.metabolomics.gnps.gnps_annotation_loader import \
GNPSAnnotationLoader
from nplinker.metabolomics.gnps.gnps_format import GNPSFormat
from nplinker.metabolomics.gnps import GNPSAnnotationLoader
from nplinker.metabolomics.gnps import GNPSFormat


@pytest.mark.parametrize("workflow, expected",
Expand Down
4 changes: 2 additions & 2 deletions tests/metabolomics/test_gnps_downloader.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import zipfile
import pytest
from nplinker.metabolomics.gnps.gnps_downloader import GNPSDownloader
from nplinker.metabolomics.gnps.gnps_format import GNPSFormat
from nplinker.metabolomics.gnps import GNPSDownloader
from nplinker.metabolomics.gnps import GNPSFormat


@pytest.fixture(scope="module", autouse=True)
Expand Down
4 changes: 2 additions & 2 deletions tests/metabolomics/test_gnps_extractor.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import filecmp
from pathlib import Path
import pytest
from nplinker.metabolomics.gnps.gnps_extractor import GNPSExtractor
from nplinker.metabolomics.gnps.gnps_format import GNPSFormat
from nplinker.metabolomics.gnps import GNPSExtractor
from nplinker.metabolomics.gnps import GNPSFormat


def test_unknown_workflow(gnps_zip_files, tmpdir):
Expand Down
5 changes: 2 additions & 3 deletions tests/metabolomics/test_gnps_file_mapping_loader.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import pytest
from nplinker.metabolomics.gnps.gnps_file_mapping_loader import \
GNPSFileMappingLoader
from nplinker.metabolomics.gnps.gnps_format import GNPSFormat
from nplinker.metabolomics.gnps import GNPSFileMappingLoader
from nplinker.metabolomics.gnps import GNPSFormat


@pytest.mark.parametrize("workflow, num_spectra, filename",
Expand Down
8 changes: 4 additions & 4 deletions tests/metabolomics/test_gnps_format.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import pytest
from nplinker.metabolomics.gnps.gnps_format import gnps_format_from_archive
from nplinker.metabolomics.gnps.gnps_format import gnps_format_from_file_mapping
from nplinker.metabolomics.gnps.gnps_format import gnps_format_from_task_id
from nplinker.metabolomics.gnps.gnps_format import GNPSFormat
from nplinker.metabolomics.gnps import gnps_format_from_archive
from nplinker.metabolomics.gnps import gnps_format_from_file_mapping
from nplinker.metabolomics.gnps import gnps_format_from_task_id
from nplinker.metabolomics.gnps import GNPSFormat


@pytest.mark.parametrize(
Expand Down
5 changes: 2 additions & 3 deletions tests/metabolomics/test_gnps_molecular_family_loader.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import pytest
from nplinker.metabolomics.gnps.gnps_format import GNPSFormat
from nplinker.metabolomics.gnps.gnps_molecular_family_loader import \
GNPSMolecularFamilyLoader
from nplinker.metabolomics.gnps import GNPSFormat
from nplinker.metabolomics.gnps import GNPSMolecularFamilyLoader


@pytest.mark.parametrize("workflow, num_families, num_spectra",
Expand Down
4 changes: 2 additions & 2 deletions tests/metabolomics/test_gnps_spectrum_loader.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest
from nplinker.metabolomics.gnps.gnps_format import GNPSFormat
from nplinker.metabolomics.gnps.gnps_spectrum_loader import GNPSSpectrumLoader
from nplinker.metabolomics.gnps import GNPSFormat
from nplinker.metabolomics.gnps import GNPSSpectrumLoader


@pytest.mark.parametrize("workflow, num_spectra",
Expand Down
2 changes: 1 addition & 1 deletion tests/metabolomics/test_load_gnps.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from itertools import chain
import pytest
from nplinker.metabolomics.gnps.gnps_format import GNPSFormat
from nplinker.metabolomics.gnps import GNPSFormat
from nplinker.metabolomics.load_gnps import _load_clusterinfo_old
from nplinker.metabolomics.load_gnps import _messy_strain_naming_lookup
from nplinker.metabolomics.load_gnps import _parse_mzxml_header
Expand Down
2 changes: 1 addition & 1 deletion tests/metabolomics/test_spectrum.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import pytest
from nplinker.metabolomics.spectrum import Spectrum
from nplinker.metabolomics import Spectrum


@pytest.fixture
Expand Down
4 changes: 2 additions & 2 deletions tests/scoring/conftest.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from pytest import fixture
from nplinker.genomics import GCF
from nplinker.metabolomics.molecular_family import MolecularFamily
from nplinker.metabolomics.spectrum import Spectrum
from nplinker.metabolomics import MolecularFamily
from nplinker.metabolomics import Spectrum
from nplinker.nplinker import NPLinker
from nplinker.scoring import MetcalfScoring
from nplinker.scoring.linking import DataLinks
Expand Down
2 changes: 1 addition & 1 deletion tests/scoring/test_data_links.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pandas as pd
from pandas.testing import assert_frame_equal
import pytest
from nplinker.metabolomics.singleton_family import SingletonFamily
from nplinker.metabolomics import SingletonFamily


def test_init(datalinks):
Expand Down
4 changes: 2 additions & 2 deletions tests/test_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import pytest
from nplinker.globals import STRAIN_MAPPINGS_FILENAME
from nplinker.loader import DatasetLoader
from nplinker.metabolomics.gnps.gnps_extractor import GNPSExtractor
from nplinker.metabolomics.gnps.gnps_spectrum_loader import GNPSSpectrumLoader
from nplinker.metabolomics.gnps import GNPSExtractor
from nplinker.metabolomics.gnps import GNPSSpectrumLoader
from nplinker.strain_collection import StrainCollection
from . import DATA_DIR

Expand Down

0 comments on commit 8b8723e

Please sign in to comment.