ebi-eva-common-pyutils 0.6.17__tar.gz → 0.7.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. {ebi_eva_common_pyutils-0.6.17 → ebi_eva_common_pyutils-0.7.1}/CHANGELOG.md +12 -0
  2. {ebi_eva_common_pyutils-0.6.17 → ebi_eva_common_pyutils-0.7.1}/PKG-INFO +1 -1
  3. {ebi_eva_common_pyutils-0.6.17 → ebi_eva_common_pyutils-0.7.1}/ebi_eva_common_pyutils/assembly/assembly.py +7 -3
  4. {ebi_eva_common_pyutils-0.6.17 → ebi_eva_common_pyutils-0.7.1}/ebi_eva_common_pyutils/biosamples_communicators.py +1 -14
  5. {ebi_eva_common_pyutils-0.6.17 → ebi_eva_common_pyutils-0.7.1}/ebi_eva_common_pyutils/logger.py +22 -8
  6. {ebi_eva_common_pyutils-0.6.17 → ebi_eva_common_pyutils-0.7.1}/ebi_eva_common_pyutils/reference/assembly.py +6 -2
  7. ebi_eva_common_pyutils-0.7.1/ebi_eva_common_pyutils/spreadsheet/metadata_xlsx_utils.py +15 -0
  8. {ebi_eva_common_pyutils-0.6.17 → ebi_eva_common_pyutils-0.7.1}/ebi_eva_common_pyutils.egg-info/PKG-INFO +1 -1
  9. {ebi_eva_common_pyutils-0.6.17 → ebi_eva_common_pyutils-0.7.1}/ebi_eva_common_pyutils.egg-info/SOURCES.txt +2 -0
  10. ebi_eva_common_pyutils-0.7.1/ebi_eva_internal_pyutils/__init__.py +0 -0
  11. {ebi_eva_common_pyutils-0.6.17 → ebi_eva_common_pyutils-0.7.1}/setup.py +1 -1
  12. {ebi_eva_common_pyutils-0.6.17 → ebi_eva_common_pyutils-0.7.1}/LICENSE +0 -0
  13. {ebi_eva_common_pyutils-0.6.17 → ebi_eva_common_pyutils-0.7.1}/MANIFEST.in +0 -0
  14. {ebi_eva_common_pyutils-0.6.17 → ebi_eva_common_pyutils-0.7.1}/README.md +0 -0
  15. {ebi_eva_common_pyutils-0.6.17 → ebi_eva_common_pyutils-0.7.1}/ebi_eva_common_pyutils/__init__.py +0 -0
  16. {ebi_eva_common_pyutils-0.6.17 → ebi_eva_common_pyutils-0.7.1}/ebi_eva_common_pyutils/assembly/__init__.py +0 -0
  17. {ebi_eva_common_pyutils-0.6.17 → ebi_eva_common_pyutils-0.7.1}/ebi_eva_common_pyutils/assembly_utils.py +0 -0
  18. {ebi_eva_common_pyutils-0.6.17 → ebi_eva_common_pyutils-0.7.1}/ebi_eva_common_pyutils/command_utils.py +0 -0
  19. {ebi_eva_common_pyutils-0.6.17 → ebi_eva_common_pyutils-0.7.1}/ebi_eva_common_pyutils/common_utils.py +0 -0
  20. {ebi_eva_common_pyutils-0.6.17 → ebi_eva_common_pyutils-0.7.1}/ebi_eva_common_pyutils/config.py +0 -0
  21. {ebi_eva_common_pyutils-0.6.17 → ebi_eva_common_pyutils-0.7.1}/ebi_eva_common_pyutils/contig_alias/__init__.py +0 -0
  22. {ebi_eva_common_pyutils-0.6.17 → ebi_eva_common_pyutils-0.7.1}/ebi_eva_common_pyutils/contig_alias/contig_alias.py +0 -0
  23. {ebi_eva_common_pyutils-0.6.17 → ebi_eva_common_pyutils-0.7.1}/ebi_eva_common_pyutils/ena_utils.py +0 -0
  24. {ebi_eva_common_pyutils-0.6.17 → ebi_eva_common_pyutils-0.7.1}/ebi_eva_common_pyutils/file_utils.py +0 -0
  25. {ebi_eva_common_pyutils-0.6.17 → ebi_eva_common_pyutils-0.7.1}/ebi_eva_common_pyutils/ncbi_utils.py +0 -0
  26. {ebi_eva_common_pyutils-0.6.17 → ebi_eva_common_pyutils-0.7.1}/ebi_eva_common_pyutils/network_utils.py +0 -0
  27. {ebi_eva_common_pyutils-0.6.17 → ebi_eva_common_pyutils-0.7.1}/ebi_eva_common_pyutils/reference/__init__.py +0 -0
  28. {ebi_eva_common_pyutils-0.6.17 → ebi_eva_common_pyutils-0.7.1}/ebi_eva_common_pyutils/reference/sequence.py +0 -0
  29. {ebi_eva_common_pyutils-0.6.17/ebi_eva_common_pyutils/taxonomy → ebi_eva_common_pyutils-0.7.1/ebi_eva_common_pyutils/spreadsheet}/__init__.py +0 -0
  30. {ebi_eva_common_pyutils-0.6.17/ebi_eva_common_pyutils/variation → ebi_eva_common_pyutils-0.7.1/ebi_eva_common_pyutils/taxonomy}/__init__.py +0 -0
  31. {ebi_eva_common_pyutils-0.6.17 → ebi_eva_common_pyutils-0.7.1}/ebi_eva_common_pyutils/taxonomy/taxonomy.py +0 -0
  32. {ebi_eva_common_pyutils-0.6.17/ebi_eva_internal_pyutils → ebi_eva_common_pyutils-0.7.1/ebi_eva_common_pyutils/variation}/__init__.py +0 -0
  33. {ebi_eva_common_pyutils-0.6.17 → ebi_eva_common_pyutils-0.7.1}/ebi_eva_common_pyutils/variation/contig_utils.py +0 -0
  34. {ebi_eva_common_pyutils-0.6.17 → ebi_eva_common_pyutils-0.7.1}/ebi_eva_common_pyutils.egg-info/dependency_links.txt +0 -0
  35. {ebi_eva_common_pyutils-0.6.17 → ebi_eva_common_pyutils-0.7.1}/ebi_eva_common_pyutils.egg-info/requires.txt +0 -0
  36. {ebi_eva_common_pyutils-0.6.17 → ebi_eva_common_pyutils-0.7.1}/ebi_eva_common_pyutils.egg-info/top_level.txt +0 -0
  37. {ebi_eva_common_pyutils-0.6.17 → ebi_eva_common_pyutils-0.7.1}/ebi_eva_internal_pyutils/archive_directory.py +0 -0
  38. {ebi_eva_common_pyutils-0.6.17 → ebi_eva_common_pyutils-0.7.1}/ebi_eva_internal_pyutils/config_utils.py +0 -0
  39. {ebi_eva_common_pyutils-0.6.17 → ebi_eva_common_pyutils-0.7.1}/ebi_eva_internal_pyutils/metadata_utils.py +0 -0
  40. {ebi_eva_common_pyutils-0.6.17 → ebi_eva_common_pyutils-0.7.1}/ebi_eva_internal_pyutils/mongo_utils.py +0 -0
  41. {ebi_eva_common_pyutils-0.6.17 → ebi_eva_common_pyutils-0.7.1}/ebi_eva_internal_pyutils/mongodb/__init__.py +0 -0
  42. {ebi_eva_common_pyutils-0.6.17 → ebi_eva_common_pyutils-0.7.1}/ebi_eva_internal_pyutils/mongodb/mongo_database.py +0 -0
  43. {ebi_eva_common_pyutils-0.6.17 → ebi_eva_common_pyutils-0.7.1}/ebi_eva_internal_pyutils/nextflow/__init__.py +0 -0
  44. {ebi_eva_common_pyutils-0.6.17 → ebi_eva_common_pyutils-0.7.1}/ebi_eva_internal_pyutils/nextflow/nextflow_pipeline.py +0 -0
  45. {ebi_eva_common_pyutils-0.6.17 → ebi_eva_common_pyutils-0.7.1}/ebi_eva_internal_pyutils/pg_utils.py +0 -0
  46. {ebi_eva_common_pyutils-0.6.17 → ebi_eva_common_pyutils-0.7.1}/ebi_eva_internal_pyutils/spring_properties.py +0 -0
  47. {ebi_eva_common_pyutils-0.6.17 → ebi_eva_common_pyutils-0.7.1}/setup.cfg +0 -0
@@ -2,6 +2,18 @@
2
2
  Changelog for ebi_eva_common_pyutils
3
3
  ===========================
4
4
 
5
+ ## 0.7.1 (2025-05-21)
6
+ ---------------------
7
+
8
+ - Make sure all loggers are debug by default
9
+
10
+
11
+ ## 0.7.0 (2025-04-14)
12
+ ----------------------
13
+
14
+ - Deprecate the AAP Authentication method
15
+
16
+
5
17
  ## 0.6.17 (2025-03-28)
6
18
  ----------------------
7
19
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ebi_eva_common_pyutils
3
- Version: 0.6.17
3
+ Version: 0.7.1
4
4
  Summary: EBI EVA - Common Python Utilities
5
5
  Home-page: https://github.com/EBIVariation/eva-common-pyutils
6
6
  License: Apache
@@ -47,14 +47,18 @@ def get_taxonomy_to_assembly_mapping_from_ensembl_rapid_release():
47
47
  strain = asm_data['strain']
48
48
  release_date = datetime.strptime(asm_data['release_date'], '%Y-%m-%d')
49
49
 
50
+ # Skip alternate haplotype assemblies
51
+ if strain and strain.lower() == 'alternate haplotype':
52
+ continue
53
+ # Skip non GCA accession
54
+ if not asm_accession.startswith('GCA_'):
55
+ continue
56
+
50
57
  # If we haven't seen this taxonomy before, just use this assembly
51
58
  if tax_id not in results:
52
59
  results[tax_id] = (asm_accession, release_date)
53
60
  continue
54
61
 
55
- # Skip alternate haplotype assemblies
56
- if strain and strain.lower() == 'alternate haplotype':
57
- continue
58
62
  current_assembly, current_date = results[tax_id]
59
63
  # Keep the more recent assembly, or the lexicographically last one if release dates are equal
60
64
  if current_date < release_date or (current_date == release_date and asm_accession > current_assembly):
@@ -50,7 +50,7 @@ class HALCommunicator(AppLogger):
50
50
 
51
51
  @cached_property
52
52
  def token(self):
53
- """Retrieve the token from the AAP REST API then cache it for further quering"""
53
+ """Retrieve the token from the REST API then cache it for further querying"""
54
54
  response = requests.get(self.auth_url, auth=(self.username, self.password))
55
55
  self._validate_response(response)
56
56
  return response.text
@@ -144,19 +144,6 @@ class HALCommunicator(AppLogger):
144
144
  def communicator_attributes(self):
145
145
  raise NotImplementedError
146
146
 
147
-
148
- class AAPHALCommunicator(HALCommunicator):
149
- """Class to navigate BioSamples API using AAP authentication."""
150
-
151
- def __init__(self, auth_url, bsd_url, username, password, domain=None):
152
- super(AAPHALCommunicator, self).__init__(auth_url, bsd_url, username, password)
153
- self.domain = domain
154
-
155
- @property
156
- def communicator_attributes(self):
157
- return {'domain': self.domain}
158
-
159
-
160
147
  class WebinHALCommunicator(HALCommunicator):
161
148
  """Class to navigate BioSamples API using Webin authentication."""
162
149
 
@@ -17,17 +17,28 @@ import logging.handlers
17
17
  from sys import stdout, stderr
18
18
  from cached_property import cached_property
19
19
 
20
+ # The way Logger/Handler/Formatter works
21
+ # - Logger create the log message
22
+ # - Formatter describe what is included in the lo message
23
+ # - Handler Propagate them to where they should go (file/screen, ...)
24
+ # Logger are part of hierarchy and always have parent up to the root logger.
25
+ # The root logger is usually set to WARNING level
26
+ # When a log is emitted to a logger, the logger checks it own level and propagate to its handler.
27
+ # If it does not have any handlers it propagates to its parent (unless propagate is set to false)
28
+ #
29
+ # SPECIAL CASE: When a logger has a level set to NOTSET (0) it inherit the level from its parent
30
+
20
31
 
21
32
  class LoggingConfiguration:
22
33
  """
23
- This class provides an all in one management of all loggers in the stack. By default it pulls existing loggers,
34
+ This class provides an all in one management of all loggers in the stack. By default, it pulls existing loggers,
24
35
  stores additional ones along with handlers and formatters.
25
36
  """
26
37
 
27
38
  default_fmt = '[%(asctime)s][%(name)s][%(levelname)s] %(message)s'
28
39
  default_datefmt = '%Y-%b-%d %H:%M:%S'
29
40
 
30
- def __init__(self, use_existing_logger=True, log_level=logging.INFO):
41
+ def __init__(self, use_existing_logger=True, log_level=logging.DEBUG):
31
42
  self.blank_formatter = logging.Formatter()
32
43
  self.handlers = set()
33
44
  if use_existing_logger:
@@ -38,6 +49,8 @@ class LoggingConfiguration:
38
49
  else:
39
50
  self.loggers = {}
40
51
  self._log_level = log_level
52
+ if log_level is not None:
53
+ self.set_log_level(log_level)
41
54
 
42
55
  @cached_property
43
56
  def formatter(self):
@@ -61,8 +74,8 @@ class LoggingConfiguration:
61
74
  else:
62
75
  logger = logging.getLogger(name)
63
76
  self.loggers[name] = logger
64
-
65
- logger.setLevel(level or self._log_level)
77
+ log_level = level if level > self._log_level else self._log_level
78
+ logger.setLevel(log_level)
66
79
  for h in self.handlers:
67
80
  logger.addHandler(h)
68
81
 
@@ -74,19 +87,20 @@ class LoggingConfiguration:
74
87
  :param logging.Handler handler:
75
88
  :param int level: Log level to assign to the created handler
76
89
  """
77
- handler.setLevel(level or self._log_level)
90
+ log_level = level if level > self._log_level else self._log_level
91
+ handler.setLevel(log_level)
78
92
  handler.setFormatter(self.formatter)
79
93
  for name in self.loggers:
80
94
  self.loggers[name].addHandler(handler)
81
95
  self.handlers.add(handler)
82
96
 
83
- def add_stdout_handler(self, level=None):
97
+ def add_stdout_handler(self, level=logging.INFO):
84
98
  self.add_handler(logging.StreamHandler(stdout), level=level or self._log_level)
85
99
 
86
- def add_stderr_handler(self, level=None):
100
+ def add_stderr_handler(self, level=logging.INFO):
87
101
  self.add_handler(logging.StreamHandler(stderr), level=level or self._log_level)
88
102
 
89
- def add_file_handler(self, filename, level=None):
103
+ def add_file_handler(self, filename, level=logging.INFO):
90
104
  self.add_handler(logging.FileHandler(filename=filename), level=level or self._log_level)
91
105
 
92
106
  def set_log_level(self, level):
@@ -236,8 +236,12 @@ class NCBIAssembly(AppLogger):
236
236
  urllib.request.urlretrieve(url, output_file)
237
237
 
238
238
  def download_or_construct(self, genbank_only=False, overwrite=False):
239
- """First download the assembly report and fasta from the FTP, then append any missing contig from
240
- the assembly report to the assembly fasta."""
239
+ """
240
+ First download the assembly report and fasta from the FTP, then append any missing contig from
241
+ the assembly report to the assembly fasta.
242
+ Setting genbank_only = True ensure that only contigs that have genbank accession will be added to the assembly fasta.
243
+ Setting overwrite = True delete any existing fasta file and assembly report. then download them again.
244
+ """
241
245
  self.download_assembly_report(overwrite)
242
246
  try:
243
247
  self.download_assembly_fasta(overwrite)
@@ -0,0 +1,15 @@
1
+ import re
2
+
3
+ from openpyxl.reader.excel import load_workbook
4
+
5
+
6
+ def metadata_xlsx_version(metadata_xlsx):
7
+ workbook = load_workbook(metadata_xlsx)
8
+ try:
9
+ instructions_sheet = workbook['PLEASE READ FIRST']
10
+ xlsx_sheet_version_value = instructions_sheet[3][0].value
11
+ match = re.search(r'(\d+\.\d+\.\d+)', '' if xlsx_sheet_version_value is None else xlsx_sheet_version_value)
12
+ xlsx_version = match.group(1) if match else None
13
+ except (KeyError, IndexError):
14
+ xlsx_version = None
15
+ return xlsx_version
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ebi-eva-common-pyutils
3
- Version: 0.6.17
3
+ Version: 0.7.1
4
4
  Summary: EBI EVA - Common Python Utilities
5
5
  Home-page: https://github.com/EBIVariation/eva-common-pyutils
6
6
  License: Apache
@@ -27,6 +27,8 @@ ebi_eva_common_pyutils/contig_alias/contig_alias.py
27
27
  ebi_eva_common_pyutils/reference/__init__.py
28
28
  ebi_eva_common_pyutils/reference/assembly.py
29
29
  ebi_eva_common_pyutils/reference/sequence.py
30
+ ebi_eva_common_pyutils/spreadsheet/__init__.py
31
+ ebi_eva_common_pyutils/spreadsheet/metadata_xlsx_utils.py
30
32
  ebi_eva_common_pyutils/taxonomy/__init__.py
31
33
  ebi_eva_common_pyutils/taxonomy/taxonomy.py
32
34
  ebi_eva_common_pyutils/variation/__init__.py
@@ -7,7 +7,7 @@ setup(
7
7
  name='ebi_eva_common_pyutils',
8
8
  scripts=[os.path.join(os.path.dirname(__file__), 'ebi_eva_internal_pyutils', 'archive_directory.py')],
9
9
  packages=find_packages(),
10
- version='0.6.17',
10
+ version='0.7.1',
11
11
  license='Apache',
12
12
  description='EBI EVA - Common Python Utilities',
13
13
  url='https://github.com/EBIVariation/eva-common-pyutils',