Ejemplo n.º 1
0
def get_fastq_individuals(store: Store, case_id: str = None) -> Iterator[str]:
    """Fetch individual ids from cases that are ready for SPRING compression"""
    case_obj = store.family(case_id)
    if not case_obj:
        LOG.error("Could not find case %s", case_id)
        raise CaseNotFoundError("")

    for link_obj in case_obj.links:
        yield link_obj.sample.internal_id
Ejemplo n.º 2
0
    def export_sample(self, days: int = 0) -> str:
        """Export sample info."""
        export_sample_parameters = ["export-sample", "-d", str(days)]

        self.process.run_command(parameters=export_sample_parameters,
                                 dry_run=self.dry_run)
        output = self.process.stdout
        # If sample not in genotype db, stdout of genotype command will be empty.
        if not output:
            raise CaseNotFoundError("samples not found in genotype db")
        return output
Ejemplo n.º 3
0
    def get_case(self, case_id: str) -> dict:
        """Find a case in the database by case id."""
        case_obj = None
        cases_parameters = ["cases", "-c", case_id, "--to-json"]

        self.process.run_command(cases_parameters)

        output = self.process.stdout

        # If case not in loqusdb, stdout of loqusdb command will be empty.
        if not output:
            raise CaseNotFoundError(f"Case {case_id} not found in loqusdb")

        case_obj = json.loads(output)[0]

        return case_obj
Ejemplo n.º 4
0
 def export_sample_analysis(self, days: int = 0) -> str:
     """Export analysis."""
     trending_call = self.base_call[:]
     trending_call.extend(["export-sample-analysis", "-d", str(days)])
     try:
         LOG.info("Running Genotype API to get data.")
         LOG.debug(trending_call)
         output = subprocess.check_output(trending_call)
     except CalledProcessError as error:
         LOG.critical("Could not run command: %s", " ".join(trending_call))
         raise error
     output = output.decode("utf-8")
     # If sample not in genotype db, stdout of genotype command will be empty.
     if not output:
         raise CaseNotFoundError("samples not found in genotype db")
     return output