def test_concept2_readonly(self): """Test that the .concept2 property is immutable.""" relObj = random.sample(self.relObjects, 1) drugsFile = StringIO(drugsData) drugObj = rxnorm.Drug(drugsFile.readline()) self.assertRaises(AttributeError, relObj.__setattr__, 'concept2', drugObj)
def make_drugObjects(self, drugsFile): """Helper function that initializes a Drug object from each line in the file object drugsFile.""" drugObjects = [] for drugLine in drugsFile: if drugLine.strip() == '': continue d = rxnorm.Drug(drugLine) drugObjects.append(d) return drugObjects
types[st.CUI] = set([st.semtype]) count += 1 display_count(count) print >> sys.stderr print >> sys.stderr, "Reading concepts" conso_filename = os.path.join(sys.argv[1], "MRCONSO.RRF") conso_file = open(conso_filename, "rU") concepts = {} count = 0 for line in conso_file: if 'RXNORM' not in line: continue c = rxnorm.Drug(line) c.semtypes = types[c.CUI] concepts[c.CUI] = c count += 1 display_count(count) print >> sys.stderr, "\nForgetting semantic type db" del types print >> sys.stderr, "Reading relations" rel_filename = os.path.join(sys.argv[1], "MRREL.RRF") rel_file = open(rel_filename, "rU") count = 0 relations = [] for line in rel_file: