forked from pradeepvemulakonda/Snomed
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Python files to add terms to both the concepts and relations.
This step is necessary so that data uploaded to Neo4j can be easily searched for.
- Loading branch information
Pradeep Vemulakonda
committed
Jun 27, 2015
1 parent
607fd0e
commit 06799d3
Showing
13 changed files
with
321,257 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
Large diffs are not rendered by default.
Oops, something went wrong.
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[FileSection] | ||
descfile = snomed_files/sct2_Description_Snapshot-en-AU_AU1000168_20150531.txt | ||
conceptfile = snomed_files/sct2_Concept_Snapshot_AU1000168_20150531.txt | ||
relfile = snomed_files/sct2_Relationship_Snapshot_AU1000168_20150531.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import configparser | ||
import os | ||
|
||
class SnomedConfig: | ||
Config = configparser.ConfigParser() | ||
Config.read(os.path.join(os.path.abspath(os.path.dirname(__file__)), 'config.ini')) | ||
|
||
def ConfigSectionMap(self, section): | ||
configMap = {} | ||
options = self.Config.options(section) | ||
for option in options: | ||
try: | ||
configMap[option] = self.Config.get(section, option) | ||
if configMap[option] == -1: | ||
DebugPrint("skip: %s" % option) | ||
except: | ||
print("exception on %s!" % option) | ||
configMap[option] = None | ||
return configMap | ||
|
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from config.read_config import SnomedConfig | ||
import csv | ||
import os | ||
|
||
sc = SnomedConfig().ConfigSectionMap("FileSection") | ||
dir = os.path.dirname(__file__) | ||
descFile = os.path.join(dir, sc["descfile"]) | ||
conceptFile = os.path.join(dir, sc["conceptfile"]) | ||
|
||
with open(descFile, "rt", encoding='utf-8') as tsvin, open("new.csv", "wb") as tsvout: | ||
dictReader = csv.DictReader(tsvin, delimiter="\t") | ||
csv.writer(tsvout) | ||
|
||
desc_result = dict( | ||
(v['conceptId'], v['term']) for v in dictReader | ||
) | ||
|
||
|
||
with open(conceptFile, 'rt', encoding='utf-8') as infile: | ||
with open('conceptOutFile.csv', 'wt', encoding='utf-8') as outfile: | ||
reader = csv.DictReader(infile, delimiter="\t") | ||
print(reader.fieldnames) | ||
# Use the same field names for the output file. | ||
fieldnames = ['id', 'effectiveTime', 'active', 'moduleId', 'definitionStatusId', 'term'] | ||
writer = csv.DictWriter(outfile, fieldnames) | ||
writer.writeheader() | ||
|
||
# Iterate over the products in the input. | ||
|
||
for concept in reader: | ||
print(concept) | ||
result = desc_result.get(concept['id'], " ") | ||
|
||
# Update the product info. | ||
concept['term'] = result | ||
|
||
# Write it to the output file. | ||
writer.writerow(concept) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
from config.read_config import SnomedConfig | ||
import csv | ||
import os | ||
|
||
sc = SnomedConfig().ConfigSectionMap("FileSection") | ||
dir = os.path.dirname(__file__) | ||
descFile = os.path.join(dir, sc["descfile"]) | ||
conceptFile = os.path.join(dir, sc["conceptfile"]) | ||
relFile = os.path.join(dir, sc["relfile"]) | ||
|
||
with open(descFile, "rt", encoding='utf-8') as tsvin, open("new.csv", "wb") as tsvout: | ||
dictReader = csv.DictReader(tsvin, delimiter="\t") | ||
csv.writer(tsvout) | ||
|
||
desc_result = dict( | ||
(v['conceptId'], v['term']) for v in dictReader | ||
) | ||
|
||
|
||
with open(relFile, 'rt', encoding='utf-8') as infile: | ||
with open('relOutFile.csv', 'wt', encoding='utf-8') as outfile: | ||
reader = csv.DictReader(infile, delimiter="\t") | ||
print(reader.fieldnames) | ||
# Use the same field names for the output file. | ||
fieldnames = ['id', 'effectiveTime', 'active', 'moduleId', 'sourceId', 'destinationId', 'relationshipGroup', 'typeId', 'characteristicTypeId', 'modifierId', 'term'] | ||
writer = csv.DictWriter(outfile, fieldnames) | ||
writer.writeheader() | ||
|
||
# Iterate over the products in the input. | ||
|
||
for rel in reader: | ||
print(rel) | ||
result = desc_result.get(rel['typeId'], " ") | ||
|
||
# Update the product info. | ||
rel['term'] = result | ||
|
||
# Write it to the output file. | ||
writer.writerow(rel) |
Empty file.
Binary file not shown.