STAR Script Add a `//` Error
1
0
Entering edit mode
15 months ago
Y ▴ 10

My script has a couple of variables pre-defined:

# Path to the genome FASTA file from Illumina iGenomes For Danio rerio (in this case):
Genome_FASTA="path/to/genome.fa"

# Path to the annotation GTF file:
Annotation_GTF="path/to/Danio_rerio.GRCz11.110.chr.gtf"

# Path to the input directory containing FASTQ files:
Input_Directory="/path/to/FQ_Folder"

# Output directory for alignment results:
Output_Directory="Path/to/Realigned_To_Ensembl_Folder_With_BAMs"

# Created the reference genome directory:
Reference="/path/to/STAR_Reference_Created_Previously"

The main script:

# Loop through each pair of paired FASTQ files in the input directory and subdirectories
for forward_file in "${Input_Directory}"/*_R1.fq; do
    # Extract the file name without extension
    file_name=$(basename "${forward_file}" _R1.fq)

    # Path to the corresponding reverse FASTQ file
    reverse_file="${forward_file/_R1/_R2}"

    echo "Forward File: ${forward_file}"
    echo "Reverse File: ${reverse_file}"
    echo "Output Directory: ${Output_Directory}"

    # Create a unique temporary directory for this sample
    TMPDIR="${Output_Directory}/${file_name}___STARtmp"

    echo "The temporary directory is: ${TMPDIR}"

    # Change working directory to the output directory
    cd "${Output_Directory}"

    echo "Made temporary directory: ${TMPDIR}"

    echo "Output Directory + Prefix: ${Output_Directory}/${file_name}___"

    # Run STAR alignment
    STAR \
        --genomeDir "${Reference}" \
        --readFilesIn "${forward_file}" "${reverse_file}" \
        --outFileNamePrefix "${Output_Directory}/${file_name}___" \
        --runThreadN "${Number_Of_Threads}" \
        --genomeLoad NoSharedMemory \
        --outSAMtype BAM SortedByCoordinate \
        --outTmpDir "${TMPDIR}" \
        --outStd Log \
        --outSAMunmapped Within \
        --outSAMattributes Standard

    # Index the generated BAM file
    samtools index "${Output_Directory}/${file_name}___Aligned.sortedByCoord.out.bam"

    rm -rf "$TMPDIR"/*

done

My error is:

Forward File: path/to/Sample-1_R1.fq
Reverse File: path/to/Sample-1_R2.fq
Output Directory: Path/to/Realigned_To_Ensembl_Folder_With_BAMs
Made temporary directory: /Path/to/Realigned_To_Ensembl_Folder_With_BAMs/Sample-1___STARtmp
Output Directory + Prefix: /Path/to/Realigned_To_Ensembl_Folder_With_BAMs/Sample-1___
Aug 13 16:50:22 ..... started STAR run
Aug 13 16:50:22 ..... loading genome
Aug 13 16:50:28 ..... started mapping
Aug 13 17:00:20 ..... finished mapping
Aug 13 17:00:21 ..... started sorting BAM

EXITING because of FATAL ERROR: failed reading from temporary file: /Path/to/Realigned_To_Ensembl_Folder_With_BAMs/Sample-1___STARtmp//BAMsort/7/48

It keeps adding a // after the the temporary directory.

I first posted it on Github here. I am not sure it was allowed on the STAR GitHub I added in some brackets {} and continued to try and modify it but I still cannot seem to get it to work. If the post is not allowed here I can take it down. I just want to resolve the issue with this script.

STAR • 897 views
ADD COMMENT
1
Entering edit mode
15 months ago
petebio ▴ 100

I don't think that the // is the problem here.

Rather, it appears that your script is trying to write to a root directory called /path which may not exists or that you may not have permission to write to.

Could you check if each of the directories + files specified by your pre-defined variables actually exist and are writable? Particularly the input directory and reference variables which both contain /path

ADD COMMENT
0
Entering edit mode

I did and it seems to be working currently (though the script is still running). Thank you.

ADD REPLY
0
Entering edit mode

Don't delete your post. I've moved petebio's comment to an answer. Please accept it to provide closure to the post.

ADD REPLY
0
Entering edit mode

Ok okay it seemed that it was an issue with an older module of STAR not an issue with the script.

ADD REPLY

Login before adding your answer.

Traffic: 2283 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6