def __init__(self, filename, target_id=None):            
        # 0. Read supplied data
        self.target_id = target_id
        self.data = parse_rdf(open(filename).read())

        # 1. For each known data type, extract relevant nodes
        var_bindings = {'record_id': self.target_id}
        self.ro = RecordObject[sp.Statement]    
        self.ro.prepare_graph(self.data, None, var_bindings)
        print "Default context", len(self.data.default_context)
        
        record_node = list(self.data.triples((None, rdf.type, sp.MedicalRecord)))
        assert len(record_node) == 1, "Found statements about >1 patient in file: %s" % record_node
        record_node = record_node[0][0]

        self.record_node = record_node
        self.ro.segregate_nodes(self.data, record_node)
        self.data.remove_context(self.data.default_context)

        # 2. Copy extracted nodes to permanent RDF store
        self.write_to_record()
        print self.data.default_context.identifier.n3()
dataset/ETHPy150Open smart-classic/smart_server/load_tools/load_one_patient.py/RecordImporter.__init__/original