healthdisparities / pastrami

A method for rapid sub-continental ancestry estimation.
7 stars 1 forks source link

plink vs plink2? Should subprocess blocks be placed in try/except blocks? #30

Closed ShivamSharma13 closed 3 years ago

ShivamSharma13 commented 3 years ago

>>>Error: The tools: plink or plink2; were listed as dependencies in the docs. I installed plink2 (through conda) which placed only plink2 in my path and not plink.

The process failed at the _subprocess.checkoutput() call in the following static function (pasted at the end).

Pastrami only checks for plink and not plink2, and throws a subprocess.CalledProcessError (check the code snippet at the post's end to see the subprocess function call).

>>>Possible Solutions:

>>>Code Snippet:

@staticmethod
    def pull_chromosome_tped(prefix, chromosome, temp_dir):
        # Pull the genotypes for a given chromosome from a given prefix
        chromosome_file_prefix = os.path.join(temp_dir, str(chromosome) + '.tmp')
        logging.info(f"Loading SNPs from chr{chromosome}")
        command = ['plink', '--tfile', prefix,
                   '--recode transpose',
                   '--chr', str(chromosome),
                   '--out', chromosome_file_prefix,
                   '--keep-allele-order']
        # TODO: Move the command to Support.run_command
        # Support.run_command(command_str=" ".join(command), shell=True)
        # Support.run_command(command_list=command)
        subprocess.check_output(" ".join(command), shell=True)

        if not os.path.isfile(chromosome_file_prefix + ".tped"):
            print(f"Failed to create {chromosome_file_prefix}.tped")
            sys.exit(1)
        ...
        ...
        ...

Pastrami seems to be running fine with plink installed (in addition to plink2).