diff options
| author | Terry Truong <terry06890@gmail.com> | 2022-06-22 01:42:41 +1000 |
|---|---|---|
| committer | Terry Truong <terry06890@gmail.com> | 2022-06-22 09:39:44 +1000 |
| commit | e78c4df403e5f98afa08f7a0841ff233d5f6d05b (patch) | |
| tree | f13dbf91228550075644be9766b4546eb20f1e1f /backend/data/genOtolData.py | |
| parent | ae1467d2ab35a03eb2d7bf3e5ca1cf4634b23443 (diff) | |
Update backend READMEs, rename some files for consistency
Diffstat (limited to 'backend/data/genOtolData.py')
| -rwxr-xr-x | backend/data/genOtolData.py | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/backend/data/genOtolData.py b/backend/data/genOtolData.py index cfb5bed..87b35c3 100755 --- a/backend/data/genOtolData.py +++ b/backend/data/genOtolData.py @@ -1,6 +1,6 @@ #!/usr/bin/python3 -import sys, re +import sys, re, os import json, sqlite3 usageInfo = f"usage: {sys.argv[0]}\n" @@ -30,8 +30,8 @@ annFile = "otol/annotations.json" dbFile = "data.db" nodeMap = {} # Maps node IDs to node objects nameToFirstId = {} # Maps node names to first found ID (names might have multiple IDs) -dupNameToIds = {} # Maps names of nodes with multiple IDs to those node IDs -pickedDupsFile = "genOtolDataPickedDups.txt" +dupNameToIds = {} # Maps names of nodes with multiple IDs to those IDs +pickedNamesFile = "pickedOtolNames.txt" # Parse treeFile print("Parsing tree file") @@ -142,10 +142,11 @@ rootId = parseNewick() # Resolve duplicate names print("Resolving duplicates") nameToPickedId = {} -with open(pickedDupsFile) as file: - for line in file: - (name, _, otolId) = line.rstrip().partition("|") - nameToPickedId[name] = otolId +if os.path.exists(pickedNamesFile): + with open(pickedNamesFile) as file: + for line in file: + (name, _, otolId) = line.rstrip().partition("|") + nameToPickedId[name] = otolId for [dupName, ids] in dupNameToIds.items(): # Check for picked id if dupName in nameToPickedId: |
