aboutsummaryrefslogtreecommitdiff
path: root/r_qtl
diff options
context:
space:
mode:
Diffstat (limited to 'r_qtl')
-rw-r--r--r_qtl/r_qtl2.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/r_qtl/r_qtl2.py b/r_qtl/r_qtl2.py
index 87491d0..0a96e7c 100644
--- a/r_qtl/r_qtl2.py
+++ b/r_qtl/r_qtl2.py
@@ -17,11 +17,26 @@ FILE_TYPES = (
"geno", "founder_geno", "pheno", "covar", "phenocovar", "gmap", "pmap",
"phenose")
+
+def __special_file__(filename):
+ """
+ Check whether the file is special in some ways, e.g. MacOSX seems to include
+ files in a directory `__MACOSX` that share parts of the name, and extensions
+ with the main files in the bundle.
+ """
+ is_macosx_special_file = filename.startswith("__MACOSX")
+ is_nix_hidden_file = Path(filename).name.startswith(".")
+
+ return (is_macosx_special_file or is_nix_hidden_file)
+
+
def control_data(zfile: ZipFile) -> dict:
"""Retrieve the control file from the zip file info."""
files = tuple(filename
for filename in zfile.namelist()
- if (filename.endswith(".yaml") or filename.endswith(".json")))
+ if (not __special_file__(filename)
+ and (filename.endswith(".yaml")
+ or filename.endswith(".json"))))
num_files = len(files)
if num_files == 0:
raise InvalidFormat("Expected a json or yaml control file.")