Exemplo n.º 1
0
def prepare_input_files(args=None):

    mkdir(args.download)
    mkdir(args.hg)
    if not exists(os.path.join(args.download, 'chromFa.tar.gz')):  
        if not download_file(args.hg, downloadURLs['hg19'], args.download):  
            raise Exception('Something went wrong while downloading the reference file')
    if not extract_file(joiner(args.download, 'chromFa.tar.gz'), joiner(args.hg, 'chromFa')):
        raise Exception('Something went wrong while extracting the reference file.')
    if not download_file('dbsnp_138.hg19.vcf.gz', downloadURLs['dbsnp'], joiner(args.hg, 'chromFa')):  
            raise Exception('Something went wrong while downloading the reference file')

    with cwd(joiner(args.hg, 'chromFa')):
        command = 'cat chrM.fa chr1.fa chr2.fa chr3.fa chr4.fa chr5.fa chr6.fa chr7.fa chr8.fa chr9.fa\
            chr10.fa chr11.fa chr12.fa chr13.fa chr14.fa chr15.fa chr16.fa chr17.fa chr18.fa\
            chr19.fa chr20.fa chr21.fa chr22.fa chrX.fa chrY.fa > hg19.fa'
        run_command(command, Exception)
        # command = 'wget ftp://[email protected]/bundle/2.8/hg19/dbsnp_138.hg19.vcf.gz 2>/dev/null'
        # run_command(command, Exception)

        command = 'gunzip -f dbsnp_138.hg19.vcf.gz'
        run_command(command, Exception)
        command = 'module add ' + ngs_tools_dict['bwa'] + ' && bwa index -a bwtsw -p hg19 hg19.fa'
        run_command(command, Exception)
        command = 'module add ' + ngs_tools_dict['SamTools'] + ' && samtools faidx hg19.fa'
        run_command(command, Exception)
        command = 'module add ' + ngs_tools_dict['Picard'] + ' && $PICARDRUN CreateSequenceDictionary REFERENCE=hg19.fa OUTPUT=hg19.dict'
        run_command(command, Exception)
    ok('  ok\n')
    return True
Exemplo n.º 2
0
def main():
    """
    Main configuration method made to be called in order to prepare reference files.
    """
    print blue("Welcome to NGS configurator\n")
    parser = argparse.ArgumentParser(description=blue('NGS configurator'))
    parser.add_argument('-download', default=joiner('downloads'), help='path to download directory')
    parser.add_argument('-hg', default=joiner('hg19'), help='path to hg19 reference files directory')
    args = parser.parse_args()
    prepare_input_files(args)