class ped_writer(unittest.TestCase): def setUp(self): self.kb = KB(driver="omero")("localhost", "root", "romeo") def tearDown(self): pass def test_base(self): def extract_data_sample(group, mset, dsample_name): by_individual = {} for i in self.kb.get_individuals(group): gds = filter(lambda x: x.snpMarkersSet == mset, self.kb.get_data_samples(i, dsample_name)) assert len(gds) == 1 by_individual[i.id] = gds[0] return by_individual study = self.kb.get_study("TEST01") family = self.kb.get_individuals(study) mset = self.kb.get_snp_markers_set(label="FakeTaqSet01") gds_by_individual = extract_data_sample(study, mset, "GenotypeDataSample") pw = PedWriter(mset, base_path="./foo") pw.write_map() pw.write_family(study.id, family, gds_by_individual) pw.close()
class ped_writer(unittest.TestCase): def setUp(self): self.kb = KB(driver='omero')('localhost', 'root', 'romeo') def tearDown(self): pass def test_base(self): def extract_data_sample(group, mset, dsample_name): by_individual = {} for i in self.kb.get_individuals(group): gds = filter(lambda x: x.snpMarkersSet == mset, self.kb.get_data_samples(i, dsample_name)) assert (len(gds) == 1) by_individual[i.id] = gds[0] return by_individual study = self.kb.get_study('TEST01') family = self.kb.get_individuals(study) mset = self.kb.get_snp_markers_set(label='FakeTaqSet01') gds_by_individual = extract_data_sample(study, mset, 'GenotypeDataSample') pw = PedWriter(mset, base_path="./foo") pw.write_map() pw.write_family(study.id, family, gds_by_individual) pw.close()
action is thought as an arrow that starts from the 'newer' object, the GenotypeDataSample instance in this case, and has as a 'target' the object on which the process operated. It is, essentially, a representation of the 'inverse' of the creation process. .. todo:: uhmmm, not sure that the Action explanation above is crystal clear :-). """ mset.load_markers() kb.update_snp_positions(mset.markers, ref_genome) data_sample_by_id = {} family = [] for i, ind in enumerate(kb.get_individuals(study)): family.append(ind) action = kb.create_an_action(study, target=ind, doc='fake dataset') conf = {'label' : 'taq-%03d' % i, 'status' : kb.DataSampleStatus.USABLE, 'action' : action, 'snpMarkersSet' : mset} data_sample = kb.factory.create(kb.GenotypeDataSample, conf).save() probs, conf = make_fake_data(mset) do = kb.add_gdo_data_object(action, data_sample, probs, conf) data_sample_by_id[ind.id] = data_sample """ .. Note how we first create a DataSample object (GenotypeDataSample) which basically keeps track of the fact that there exists a genotyping
action is thought as an arrow that starts from the 'newer' object, the GenotypeDataSample instance in this case, and has as a 'target' the object on which the process operated. It is, essentially, a representation of the 'inverse' of the creation process. .. todo:: uhmmm, not sure that the Action explanation above is crystal clear :-). """ mset.load_markers() kb.update_snp_positions(mset.markers, ref_genome) data_sample_by_id = {} family = [] for i, ind in enumerate(kb.get_individuals(study)): family.append(ind) action = kb.create_an_action(study, target=ind, doc='fake dataset') conf = { 'label': 'taq-%03d' % i, 'status': kb.DataSampleStatus.USABLE, 'action': action, 'snpMarkersSet': mset } data_sample = kb.factory.create(kb.GenotypeDataSample, conf).save() probs, conf = make_fake_data(mset) do = kb.add_gdo_data_object(action, data_sample, probs, conf) data_sample_by_id[ind.id] = data_sample """ .. Note how we first create a DataSample object (GenotypeDataSample)