From f949a1e6815907af9cb41f63c18a6fdcc3e188ca Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bertrand=20N=C3=A9ron?= <bneron@pasteur.fr>
Date: Thu, 21 Jan 2016 15:42:12 +0100
Subject: [PATCH] file containig system info could refer replicon which are not
 in replicon file

so skip these systems and log them
---
 src/parser/parser.py | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/parser/parser.py b/src/parser/parser.py
index 278aa55..68dced2 100755
--- a/src/parser/parser.py
+++ b/src/parser/parser.py
@@ -179,13 +179,19 @@ def fill_db(server_uri, db_name, user, passwd, replicon_db, system_db, force_upd
     secreton_db = server.get_or_create_db(db_name)
     system_codes = system_db.keys()
     system_codes.sort()
+    print("number of documents:", len(system_codes), file=sys.stderr)
     for syst_code in system_codes:
         system = system_db[syst_code]
-        replicon = replicon_db[system.replicon]
+        try:
+            replicon = replicon_db[system.replicon]
+        except KeyError:
+            print("ERROR Replicon {0} referenced in system annotation file is not present in replicon information file: replicon skipped")
+            continue
         secretion_system = SecretionSystem()
         secretion_system._id = system.code
         secretion_system.code = system.code
         secretion_system.predicted_system = system.predicted_system
+        secretion_system.system_status = system.system_status
         secretion_system.replicon = {'name': replicon.name,
                                      'ncbi_id': replicon.ncbi_id,
                                      'taxid': replicon.taxid,
-- 
GitLab