Skip to content

Commit

Permalink
- Slight modifications to initialization and error reporting after
Browse files Browse the repository at this point in the history
    experimenting with RepeatMasker 4.1.6
  • Loading branch information
Robert Hubley committed Dec 4, 2023
1 parent 337c921 commit b44f359
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 21 deletions.
4 changes: 2 additions & 2 deletions famdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -845,8 +845,8 @@ def main(): # =================================================================
except:
args.db_dir = None
exc_value = sys.exc_info()[1]
#LOGGER.error("Error reading file: %s", exc_value)
#if LOGGER.getEffectiveLevel() <= logging.DEBUG:
# LOGGER.error("Error reading file: %s", exc_value)
# if LOGGER.getEffectiveLevel() <= logging.DEBUG:
# raise
raise
else:
Expand Down
27 changes: 8 additions & 19 deletions famdb_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -654,53 +654,42 @@ def __init__(self, db_dir, mode):
# A partioned famdb file is named *.#.h5 where
# the number represents the partition number and
# at a minimum partitition 0 must be present.
db_roots = {}
export_names = {}
db_prefixes = {}
h5_files = []
for file in os.listdir(db_dir):
if file.endswith(".h5"):
h5_files += [file]
export_name = file[:-5]
if export_name in export_names:
export_names[export_name] += 1
else:
export_names[export_name] = 1
if file.endswith(".0.h5"):
db_roots[file[:-5]] = 1

# Make sure all files in directory have same name
if len(export_names) != 1:
LOGGER.error("A directory should include exactly one FamDB export")
exit(1)
db_prefixes[file[:-5]] = 1

# Make sure we only have at least one database present
if len(db_roots) == 0:
if len(db_prefixes) == 0:
if h5_files:
LOGGER.error(
"A partitioned famdb database is not present in "
+ db_dir
+ "\n"
+ "There were several *.h5 files present however, they do not appear\n"
+ "There were several *.h5 files present. However, they do not appear\n"
+ "to be in the correct format: "
+ "\n".join(h5_files)
+ "\n"
)
else:
LOGGER.error("A partitioned famdb database is not present in " + db_dir )
LOGGER.error("A partitioned famdb database is not present in " + db_dir)
exit(1)

# Make sure we have *only* one database present
if len(db_roots) > 1:
if len(db_prefixes) > 1:
LOGGER.error(
"Multiple famdb root partitions were found in this export directory: "
+ ", ".join(db_roots.keys())
+ ", ".join(db_prefixes.keys())
+ "\nEach famdb database "
+ "should be in separate folders."
)
exit(1)

# Tabulate all partitions for db_prefix
db_prefix = list(db_roots.keys())[0]
db_prefix = list(db_prefixes.keys())[0]
for file in h5_files:
if db_prefix in file:
fields = file.split(".")
Expand Down

0 comments on commit b44f359

Please sign in to comment.