def _prepare_samples(self): """ private method to load sample information """ if not self.args.no_genotypes: self.samples = self.vcf_reader.samples self.sample_to_id = {} for idx, sample in enumerate(self.samples): self.sample_to_id[sample] = idx + 1 self.ped_hash = {} if self.args.ped_file is not None: self.ped_hash = load_ped_file(self.args.ped_file) sample_list = [] for sample in self.samples: i = self.sample_to_id[sample] if sample in self.ped_hash: fields = self.ped_hash[sample] sample_list = [i] + fields elif len(self.ped_hash) > 0: sys.exit("EXITING: sample %s found in the VCF but " "not in the PED file.\n" % (sample)) else: # if there is no ped file given, just fill in the name and # sample_id and set the other required fields to None sample_list = [i, None, sample] sample_list += list(repeat(None, len(default_ped_fields) - 2)) database.insert_sample(self.c, sample_list)
def _prepare_samples(self): """ private method to load sample information """ if not self.args.no_genotypes: self.samples = self.vcf_reader.samples self.sample_to_id = {} for idx, sample in enumerate(self.samples): self.sample_to_id[sample] = idx + 1 self.ped_hash = {} if self.args.ped_file is not None: self.ped_hash = load_ped_file(self.args.ped_file) sample_list = [] for sample in self.samples: i = self.sample_to_id[sample] if sample in self.ped_hash: fields = self.ped_hash[sample] sample_list = [i] + fields elif len(self.ped_hash) > 0: raise ValueError("Sample %s found in the VCF but " "not in the PED file.\n" % (sample)) else: # if there is no ped file given, just fill in the name and # sample_id and set the other required fields to None sample_list = [i, 0, sample, 0, 0, -9, -9] database.insert_sample(self.c, self.metadata, sample_list)
def _prepare_samples(self): """ private method to load sample information """ if not self.args.no_genotypes: self.samples = self.vcf_reader.samples self.sample_to_id = {} for idx, sample in enumerate(self.samples): self.sample_to_id[sample] = idx + 1 self.ped_hash = {} if self.args.ped_file is not None: for line in open(self.args.ped_file, "r"): field = line.strip().split("\t") if len(field) > 1 and not field[0].startswith("#"): ped = pedformat(field) self.ped_hash[ped.name] = ped sample_list = [] for sample in self.samples: i = self.sample_to_id[sample] if self.ped_hash.has_key(sample): ped = self.ped_hash[sample] sample_list = [i, sample, ped.family, ped.paternal, ped.maternal, ped.sex, ped.phenotype, ped.ethnicity] else: sample_list = [i, sample, None, None, None, None, None, None] database.insert_sample(self.c, sample_list)
def _prepare_samples(self): """ private method to load sample information """ if not self.args.no_genotypes: self.samples = self.vcf_reader.samples self.sample_to_id = {} for idx, sample in enumerate(self.samples): self.sample_to_id[sample] = idx + 1 self.ped_hash = {} if self.args.ped_file is not None: for line in open(self.args.ped_file, 'r'): field = line.strip().split("\t") if len(field) > 1 and not field[0].startswith("#"): ped = pedformat(field) self.ped_hash[ped.name] = ped sample_list = [] for sample in self.samples: i = self.sample_to_id[sample] if self.ped_hash.has_key(sample): ped = self.ped_hash[sample] sample_list = [ i, sample, ped.family, ped.paternal, ped.maternal, ped.sex, ped.phenotype, ped.ethnicity ] else: sample_list = [i, sample, None, None, None, None, None, None] database.insert_sample(self.c, sample_list)