Exemple #1
0
def extract_file(path, destination, flags=''):
    print ' Extracting file: ' + path + ' into: ' + destination
    mkdir(destination)
    command = 'tar xf ' + path + ' -C ' + destination + ' ' + flags
    run_command(command, Exception)
    ok('  ok\n')
    return True
Exemple #2
0
def exists(path):
    print ' Checking for existence of: ' + path
    if os.path.isfile(path):
        ok('Already here: \n    ' + path)
        return True
    warning('Not here!')
    return False
Exemple #3
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