src/utilities/rna_velocity/run_velocyto_star.py
def run_sample(
    sample_key,
    mask_path,
    gtf_path,
    s3_input_bucket,
    s3_output_bucket,
    s3_output_prefix,
    run_dir,
    logger,
):
    """ Run RNA velocity analysis with Velocyto on smartseq2 data aligned with STAR.

        sample_key - Sample alignment result file name that ends with ".bam"
        mask_path - .gtf file containing intervals to mask (i.e. genes not considered for RNA velocity analysis)
        gtf_path - Path to the .gtf file used for velocyto run
        s3_input_bucket - Name of the bucket with smartseq2 alignment results
        s3_output_bucket - Name of the bucket to store smartseq2 velocyto results
        s3_output_prefix - Pathname under the output bucket to store smartseq2 velocyto results
        run_dir - Path local to the machine on EC2 under which alignment results
                  are stored before uploaded to S3
        logger - Logger object that exposes the interface the code directly uses
    """

    t_config = TransferConfig(num_download_attempts=25)

    sample_name = os.path.basename(sample_key)
    sample_id = sample_name.split(".")[0]  # this is brittle!
    local_sample = os.path.join(run_dir, "input", sample_name)

    s3c.download_file(
        Bucket=s3_input_bucket, Key=sample_key, Filename=local_sample, Config=t_config
    )

    veloctyo_command = [
        "velocyto",
        "run-smartseq2",
        "-o",
        run_dir,
        "-m",
        mask_path,
        "-e",
        sample_id,
        local_sample,
        gtf_path,
    ]

    if ut_log.log_command(
        logger,
        veloctyo_command,
        stdout=subprocess.PIPE,
        stderr=subprocess.STDOUT,
        shell=True,
    ):
        logger.info(f"velocyto failed on {sample_id}")
        os.remove(local_sample)
        return

    output_file = os.path.join(run_dir, f"{sample_id}.loom")

    logger.info("Uploading {}".format(output_file))
    time.sleep(10)
    s3c.upload_file(
        Filename=output_file,
        Bucket=s3_output_bucket,
        Key=os.path.join(s3_output_prefix, f"{sample_id}.loom"),
        Config=t_config,
    )

    os.remove(local_sample)
    os.remove(output_file)
 Run RNA velocity analysis with Velocyto on smartseq2 data aligned with STAR.

        sample_key - Sample alignment result file name that ends with ".bam"
        mask_path - .gtf file containing intervals to mask (i.e. genes not considered for RNA velocity analysis)
        gtf_path - Path to the .gtf file used for velocyto run
        s3_input_bucket - Name of the bucket with smartseq2 alignment results
        s3_output_bucket - Name of the bucket to store smartseq2 velocyto results
        s3_output_prefix - Pathname under the output bucket to store smartseq2 velocyto results
        run_dir - Path local to the machine on EC2 under which alignment results
                  are stored before uploaded to S3
        logger - Logger object that exposes the interface the code directly uses
    
Run RNA velocity analysis with Velocyto on smartseq2 data aligned with STAR.
Run RNA velocity analysis with Velocyto on smartseq2 data aligned with STAR .
def run_sample(
    sample_key,
    mask_path,
    gtf_path,
    s3_input_bucket,
    s3_output_bucket,
    s3_output_prefix,
    run_dir,
    logger,
):
    t_config = TransferConfig(num_download_attempts=25)
    sample_name = os.path.basename(sample_key)
    sample_id = sample_name.split(".")[0]  
    local_sample = os.path.join(run_dir, "input", sample_name)
    s3c.download_file(
        Bucket=s3_input_bucket, Key=sample_key, Filename=local_sample, Config=t_config
    )
    veloctyo_command = [
        "velocyto",
        "run-smartseq2",
        "-o",
        run_dir,
        "-m",
        mask_path,
        "-e",
        sample_id,
        local_sample,
        gtf_path,
    ]
    if ut_log.log_command(
        logger,
        veloctyo_command,
        stdout=subprocess.PIPE,
        stderr=subprocess.STDOUT,
        shell=True,
    ):
        logger.info(f"velocyto failed on {sample_id}")
        os.remove(local_sample)
        return
    output_file = os.path.join(run_dir, f"{sample_id}.loom")
    logger.info("Uploading {}".format(output_file))
    time.sleep(10)
    s3c.upload_file(
        Filename=output_file,
        Bucket=s3_output_bucket,
        Key=os.path.join(s3_output_prefix, f"{sample_id}.loom"),
        Config=t_config,
    )
    os.remove(local_sample)
    os.remove(output_file)
def run_sample ( sample_key , mask_path , gtf_path , s3_input_bucket , s3_output_bucket , s3_output_prefix , run_dir , logger , ) : t_config = TransferConfig ( num_download_attempts = 25 ) sample_name = os . path . basename ( sample_key ) sample_id = sample_name . split ( "." ) [ 0 ] local_sample = os . path . join ( run_dir , "input" , sample_name ) s3c . download_file ( Bucket = s3_input_bucket , Key = sample_key , Filename = local_sample , Config = t_config ) veloctyo_command = [ "velocyto" , "run-smartseq2" , "-o" , run_dir , "-m" , mask_path , "-e" , sample_id , local_sample , gtf_path , ] if ut_log . log_command ( logger , veloctyo_command , stdout = subprocess . PIPE , stderr = subprocess . STDOUT , shell = True , ) : logger . info ( f"velocyto failed on {sample_id}" ) os . remove ( local_sample ) return output_file = os . path . join ( run_dir , f"{sample_id}.loom" ) logger . info ( "Uploading {}" . format ( output_file ) ) time . sleep ( 10 ) s3c . upload_file ( Filename = output_file , Bucket = s3_output_bucket , Key = os . path . join ( s3_output_prefix , f"{sample_id}.loom" ) , Config = t_config , ) os . remove ( local_sample ) os . remove ( output_file )
Run RNA velocity analysis with Velocyto on smartseq2 data aligned with STAR.
Run RNA velocity analysis with Velocyto on smartseq2 data aligned with STAR .
""" Run RNA velocity analysis with Velocyto on smartseq2 data aligned with STAR.

        sample_key - Sample alignment result file name that ends with ".bam"
        mask_path - .gtf file containing intervals to mask (i.e. genes not considered for RNA velocity analysis)
        gtf_path - Path to the .gtf file used for velocyto run
        s3_input_bucket - Name of the bucket with smartseq2 alignment results
        s3_output_bucket - Name of the bucket to store smartseq2 velocyto results
        s3_output_prefix - Pathname under the output bucket to store smartseq2 velocyto results
        run_dir - Path local to the machine on EC2 under which alignment results
                  are stored before uploaded to S3
        logger - Logger object that exposes the interface the code directly uses
    """ # this is brittle!
sample_key
mask_path
gtf_path
s3_input_bucket
s3_output_bucket
s3_output_prefix
run_dir
logger