From 62ce102ec29b80d8fa3f52c8c7161461294ef1ec Mon Sep 17 00:00:00 2001 From: Manuel Holtgrewe Date: Wed, 20 Oct 2021 09:58:20 +0200 Subject: [PATCH] Fixing bugs in import. --- importer/management/commands/import_tables.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/importer/management/commands/import_tables.py b/importer/management/commands/import_tables.py index c8983169e..6884b5ce1 100644 --- a/importer/management/commands/import_tables.py +++ b/importer/management/commands/import_tables.py @@ -637,13 +637,15 @@ def _replace_pk_in_kegg_and_import(self, mapping, path, release_info, table, for tmp.flush() return self._import(tmp.name, release_info, table, force=force, truncate=truncate) - def _import_gnomad(self, path, tables, force): - self._import_chromosome_wise(path, tables, force, list(range(1, 23)) + ["X"]) + def _import_gnomad(self, path, tables, force, truncate): + self._import_chromosome_wise(path, tables, force, truncate, list(range(1, 23)) + ["X"]) - def _import_dbsnp(self, path, tables, force): - self._import_chromosome_wise(path, tables, force, list(range(1, 23)) + ["X", "Y", "MT"]) + def _import_dbsnp(self, path, tables, force, truncate): + self._import_chromosome_wise( + path, tables, force, truncate, list(range(1, 23)) + ["X", "Y", "MT"] + ) - def _import_chromosome_wise(self, path, tables, force, chroms): + def _import_chromosome_wise(self, path, tables, force, truncate, chroms): """Wrapper function to import gnomad tables :param path: Path to gnomad tables @@ -651,7 +653,7 @@ def _import_chromosome_wise(self, path, tables, force, chroms): :return: Nothing """ # Import file is scattered into chromosome pieces, collect them. - for chrom in chroms: + for no, chrom in enumerate(chroms): # If the any chromosome can't be imported, don't try to import the other chromosomes. if not self._import( # Add chromosome to file name @@ -660,5 +662,6 @@ def _import_chromosome_wise(self, path, tables, force, chroms): # Import into info table only once chrom == 1, force=force, + truncate=truncate and no == 0, ): break