<commit_before>"""Prepare supplemental files to work with RNA-seq transcriptome experiments.

Retrieves annotations in a format usable by Cufflinks, using repositories
provided by Illumina:

http://cufflinks.cbcb.umd.edu/igenomes.html
"""
import os

from fabric.api import *
from fabric.contrib.files import *

def download_transcripts(genomes, env):
    folder_name = "rnaseq"
    base_url = "https://s3.amazonaws.com/biodata/annotation/{gid}-rnaseq.tar.xz"
    genome_dir = os.path.join(env.data_files, "genomes")
    for (orgname, gid, manager) in ((o, g, m) for (o, g, m) in genomes
                                    if m.config.get("rnaseq", False)):
        org_dir = os.path.join(genome_dir, orgname)
        tx_dir = os.path.join(org_dir, gid, folder_name)
        if not env.safe_exists(tx_dir):
            with cd(org_dir):
                _download_annotation_bundle(env, base_url.format(gid=gid), gid)

def _download_annotation_bundle(env, url, gid):
    """Download bundle of RNA-seq data from S3 biodata/annotation
    """
    tarball = os.path.basename(url)
    if not env.safe_exists(tarball):
        with warn_only():
            env.safe_run("wget %s" % url)
    if exists(tarball):
        env.safe_run("xz -dc %s | tar -xvpf -" % tarball)
        env.safe_run("rm -f %s" % tarball)
    else:
        env.logger.warn("RNA-seq transcripts not available for %s" % gid)<commit_msg>One final fix for local transcript download. Fixes chapmanb/bcbio-nextgen#88<commit_after>"""Prepare supplemental files to work with RNA-seq transcriptome experiments.

Retrieves annotations in a format usable by Cufflinks, using repositories
provided by Illumina:

http://cufflinks.cbcb.umd.edu/igenomes.html
"""
import os

from fabric.api import *
from fabric.contrib.files import *

def download_transcripts(genomes, env):
    folder_name = "rnaseq"
    base_url = "https://s3.amazonaws.com/biodata/annotation/{gid}-rnaseq.tar.xz"
    genome_dir = os.path.join(env.data_files, "genomes")
    for (orgname, gid, manager) in ((o, g, m) for (o, g, m) in genomes
                                    if m.config.get("rnaseq", False)):
        org_dir = os.path.join(genome_dir, orgname)
        tx_dir = os.path.join(org_dir, gid, folder_name)
        if not env.safe_exists(tx_dir):
            with cd(org_dir):
                _download_annotation_bundle(env, base_url.format(gid=gid), gid)

def _download_annotation_bundle(env, url, gid):
    """Download bundle of RNA-seq data from S3 biodata/annotation
    """
    tarball = os.path.basename(url)
    if not env.safe_exists(tarball):
        with warn_only():
            env.safe_run("wget %s" % url)
    if env.safe_exists(tarball):
        env.safe_run("xz -dc %s | tar -xvpf -" % tarball)
        env.safe_run("rm -f %s" % tarball)
    else:
        env.logger.warn("RNA-seq transcripts not available for %s" % gid)
{'fraction_non_alphanumeric': 0.12143354210160055, 'fraction_numerical': 0.0020876826722338203, 'mean_word_length': 2.9764868603042878, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 11, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6856328', 'n_tokens_mistral': 1008, 'n_tokens_neox': 952, 'n_words': 237}