Skip to content

Commit

Permalink
Replace deprecated path API usage (#71)
Browse files Browse the repository at this point in the history
* Update NEWS with information on deprecation changes. Update pyproject.toml with new minimum path library version.
* Update "path.py" pypi package to its rename of "path"
  • Loading branch information
EricR86 authored Sep 26, 2024
1 parent 3a7d7ed commit c3c94bc
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 15 deletions.
11 changes: 8 additions & 3 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
1.7.3:
* replace deprecated .isdir and .isfile path API uses with is_dir and is_file
from version 16.12
* add numpy 2.0 compatibilty

1.7.2:
* required Python is now >=3.9
* fixed consistency in array shape output when track indexing on bigWig files
Expand Down Expand Up @@ -129,7 +134,7 @@

1.2.3:

* DO NOT USE: genomedata-load-seq doesn't work
* DO NOT USE: genomedata-load-seq doesn't work
* allow use with PyTables >=2.2
* new command: genomedata-info: "genomedata-info tracknames ARCHIVE"
prints the tracknames for ARCHIVE
Expand Down Expand Up @@ -188,7 +193,7 @@
the handling of non-context-manager Genome objects by requiring a call
to Genome.close() when finished.
* Added an option to genomedata-load-seq and genomedata-load
to specify the Genomedata archive implementation (directory/file).
to specify the Genomedata archive implementation (directory/file).
Default is directory if number of sequences is at least 100.
* Added support for replacing data in Genomedata tracks.
* General documentation improvements
Expand All @@ -210,7 +215,7 @@
* extend documentation, including examples
* extended API with: chromosome[start:end], chromosome.seq[start:end],
and chromosome.supercontigs[start:end]
* added reasonable repr and str return values for Genome, Chromosome,
* added reasonable repr and str return values for Genome, Chromosome,
and Supercontig

0.1.5:
Expand Down
4 changes: 2 additions & 2 deletions genomedata/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def __init__(self, filename, *args, **kwargs):
raise IOError("Could not find Genomedata archive: %s" % filepath)

# If it's a file we are opening
if filepath.isfile():
if filepath.is_file():
# Check if the file type is bigWig
# NB: Could consider checking by filename extension only
if is_big_wig(filepath):
Expand All @@ -110,7 +110,7 @@ def __init__(self, filename, *args, **kwargs):
else:
self._chromosomes = _HDF5SingleFileChromosomeList(
filepath, *args, **kwargs)
elif filepath.isdir():
elif filepath.is_dir():
# Genomedata directory
self._chromosomes = _HDF5DirectoryChromosomeList(filepath, *args,
**kwargs)
Expand Down
2 changes: 1 addition & 1 deletion genomedata/_load_seq.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ def load_seq(gdfilename, filenames, verbose=False, mode=None,
print(msg, file=sys.stderr)
if mode == "dir":
if gdpath.exists():
assert gdpath.isdir()
assert gdpath.is_dir()
else:
gdpath.makedirs()
elif mode == "file":
Expand Down
8 changes: 4 additions & 4 deletions genomedata/load_genomedata.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def load_genomedata(gdfilename, tracks=None, seqfilenames=None, mode=None,
else:
seqfile_desc = "assembly"

if not Path(seqfilename).isfile():
if not Path(seqfilename).is_file():
die("Could not find %s file: %s" % (seqfile_desc, seqfilename))

if verbose:
Expand All @@ -112,7 +112,7 @@ def load_genomedata(gdfilename, tracks=None, seqfilenames=None, mode=None,
try:
track_names = []
for track_name, track_filename in tracks:
if Path(track_filename).isfile():
if Path(track_filename).is_file():
if track_name not in track_names: # No duplicates
track_names.append(track_name)
else:
Expand Down Expand Up @@ -152,7 +152,7 @@ def load_genomedata(gdfilename, tracks=None, seqfilenames=None, mode=None,
# Move/repack h5 files to output directory
if isdir: # Repack each h5 file separately
if gdpath.exists():
assert gdpath.isdir()
assert gdpath.is_dir()
else:
gdpath.makedirs()

Expand All @@ -173,7 +173,7 @@ def load_genomedata(gdfilename, tracks=None, seqfilenames=None, mode=None,
print(">> Cleaning up...", end=' ', file=sys.stderr)

sys.stdout.flush()
if tempdatapath.isfile():
if tempdatapath.is_file():
tempdatapath.remove()
else:
tempdatapath.rmtree()
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ dependencies = [
"tables>=3.0,!=3.4.1",
"six",
"textinput>=0.2.0",
"path.py>=11",
"path>=16.12",
"pybigwig",
]
description = "tools for accessing large amounts of genomic data"
Expand Down
8 changes: 4 additions & 4 deletions test/test_genomedata.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,10 +297,10 @@ def setUp(self):
for chrom in self.chroms:
filename = os.extsep.join([chrom, "genomedata"])
filepath = self.gdfilepath.joinpath(filename)
self.assertTrue(filepath.isfile(),
self.assertTrue(filepath.is_file(),
"Chromosome file was not found: %s" % filepath)
elif self.mode == "file":
self.assertTrue(self.gdfilepath.isfile(),
self.assertTrue(self.gdfilepath.is_file(),
"Genomedata archive was not created: %r" %
self.gdfilepath)
else:
Expand Down Expand Up @@ -481,10 +481,10 @@ def setUp(self):
for chrom in self.chroms:
filename = os.extsep.join([chrom, "genomedata"])
filepath = self.gdfilepath.joinpath(filename)
self.assertTrue(filepath.isfile(),
self.assertTrue(filepath.is_file(),
"Chromosome file was not found: %s" % filepath)
elif self.mode == "file":
self.assertTrue(self.gdfilepath.isfile(),
self.assertTrue(self.gdfilepath.is_file(),
"Genomedata archive was not created: %r" %
self.gdfilepath)
else:
Expand Down

0 comments on commit c3c94bc

Please sign in to comment.