Get the individuals from a vcf file, gemini database, and/or a ped file.

            Args:
                variant_source (str): Path to a variant source
                case_lines(Iterable): Ped like lines
                case_type(str): Format of ped lines

            Returns:
                individuals (generator): generator with Individuals

def get_individuals(variant_source, case_lines=None, case_type='ped', variant_mode='vcf'):
        """Get the individuals from a vcf file, gemini database, and/or a ped file.

            Args:
                variant_source (str): Path to a variant source
                case_lines(Iterable): Ped like lines
                case_type(str): Format of ped lines

            Returns:
                individuals (generator): generator with Individuals
        """
        individuals = []
        ind_dict ={}

        if variant_mode == 'vcf':
            head = get_header(variant_source)
            #Dictionary with ind_id:index where index show where in vcf ind info is

            for index, ind in enumerate(head.individuals):
                ind_dict[ind] = index

            if case_lines:
                # read individuals from ped file
                family_parser = FamilyParser(case_lines, family_type=case_type)
                families = family_parser.families
                logger.debug("Found families {0}".format(
                            ','.join(list(families.keys()))))
                if len(families) != 1:
                    logger.error("Only one family can be used with vcf adapter")
                    raise IOError

                case_id = list(families.keys())[0]
                logger.debug("Family used in analysis: {0}".format(case_id))

                for ind_id in family_parser.individuals:
                    ind = family_parser.individuals[ind_id]
                    logger.info("Found individual {0}".format(ind.individual_id))
                    try:
                        individual = Individual(
                            ind_id=ind_id,
                            case_id=case_id,
                            mother=ind.mother,
                            father=ind.father,
                            sex=str(ind.sex),
                            phenotype=str(ind.phenotype),
                            variant_source=variant_source,
                            ind_index=ind_dict[ind_id],
                            )
                        individuals.append(individual)
                    except KeyError as err:
                        #This is the case when individuals in ped does not exist
                        #in vcf
                        raise PedigreeError(
                            family_id=case_id,
                            individual_id=ind_id,
                            message="Individual {0} exists in ped file but not in vcf".format(ind_id)
                            )

            else:
                case_id = os.path.basename(variant_source)

                for ind in ind_dict:
                    individual = Individual(
                        ind_id=ind,
                        case_id=case_id,
                        variant_source=variant_source,
                        ind_index=ind_dict[ind]
                        )
                    individuals.append(individual)

                    logger.debug("Found individual {0} in {1}".format(
                                 ind, variant_source))
        elif variant_mode == 'gemini':
            gq = GeminiQuery(variant_source)
            #Dictionaru with sample to index in the gemini database
            ind_dict = gq.sample_to_idx
            query = "SELECT * from samples"
            gq.run(query)
            for individual in gq:
                logger.debug("Found individual {0} with family id {1}".format(
                    individual['name'], individual['family_id']))
                individuals.append(
                    Individual(
                        ind_id=individual['name'],
                        case_id=individual['family_id'],
                        mother=individual['maternal_id'],
                        father=individual['paternal_id'],
                        sex=individual['sex'],
                        phenotype=individual['phenotype'],
                        ind_index=ind_dict.get(individual['name']),
                        variant_source=variant_source,
                        bam_path=None)
                        )

        return individuals