-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
uqsdemon
committed
Aug 28, 2024
0 parents
commit 11ed909
Showing
12 changed files
with
6,093 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#!/usr/bin/bash | ||
|
||
# load modules | ||
module load sra-tools | ||
module load samtools | ||
|
||
help(){ | ||
echo "Usage: use this script to convert SRA files to fastq or bam" | ||
echo | ||
echo "Options :" | ||
echo " -b : convert to bam file. " | ||
echo " -q : convert to fastq file. " | ||
echo " -h : show this help message and exit" | ||
echo | ||
echo " dont forget to change the output directory inside the script" | ||
echo "if not the output will be ./" | ||
exit 1 | ||
} | ||
|
||
# change your own path here | ||
destination="./" | ||
|
||
conversion_type="" | ||
|
||
while getopts "bq:h" op; do | ||
case $op in | ||
q) | ||
conversion_type="fastq" | ||
;; | ||
b) | ||
conversion_type="bam" | ||
;; | ||
h) | ||
help | ||
;; | ||
\?) | ||
echo "wrong operator: -$OPTARG" >&2 | ||
help | ||
;; | ||
esac | ||
done | ||
|
||
if [ -z "$conversion_type" ]; then | ||
echo " you need to specify a conversion option: -q or -b" | ||
help | ||
fi | ||
|
||
find . -name "*.sra" -exec mv {} $destination \; | ||
|
||
for sra_file in $destination*.sra; do | ||
echo "running $sra_file..." | ||
|
||
base_name=$(basename "$sra_file" .sra) | ||
|
||
case $conversion_type in | ||
fastq) | ||
echo "conversion of $sra_file in fastq...." | ||
fastq-dump.3 --ngc a.ngc "$sra_file" | ||
;; | ||
bam) | ||
echo "conversion of $sra_file in bam....." | ||
sam_dump.3 --ngc a.ngc $sra_file | samtools view -bS - > "${base_name}.bam" | ||
;; | ||
esac | ||
|
||
done | ||
|
||
echo "treatment's over" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#!/usr/bin/bash | ||
help(){ | ||
echo "this script is going to download the SRA files from a sra list provided after sorting the id from a sra table" | ||
echo "and place them inside of a new folder" | ||
echo "no argument is needed" | ||
echo | ||
echo " this script is functioning if the table file has a header" | ||
echo " if not, just change the done by the one behind a #" | ||
exit 1 | ||
} | ||
# Add sratoolkit to PATH | ||
export PATH="/scratch/user/uqsdemon/ApplicationGNN/gnnenvo/bin/sratoolkit.3.1.1-ubuntu64/bin:$PATH" | ||
|
||
# Charger les modules nécessaires (if still required) | ||
module load sra-tools | ||
module load samtools | ||
|
||
# Chemin du fichier contenant les identifiants SRR | ||
fastq_ids_file="/scratch/user/uqsdemon/rnewbashscriptvf/SRRIDS/fastq_ids.txt" | ||
# Liste des identifiants à exclure | ||
exclude_ids_file="/scratch/user/uqsdemon/rnewbashscriptvf/filedone.txt" | ||
outputpath="/QRISdata/Q7361/SRRIDS/fastqfilesncbi" | ||
keypath="/scratch/user/uqsdemon/rnewbashscriptvf/prj_33410_D38764.ngc" | ||
|
||
# Vérifiez que sra-tools est chargé correctement | ||
if ! command -v fasterq-dump &> /dev/null; then | ||
echo "fasterq-dump could not be found. Please check your sratoolkit installation and PATH." | ||
help | ||
fi | ||
|
||
if [ ! -f "$fastq_ids_file" ]; then | ||
echo "Error: the file with sra ids does not exist." | ||
help | ||
fi | ||
|
||
if [ ! -f "$keypath" ]; then | ||
echo "Erreur : le fichier NGC n'existe pas au chemin spécifié." | ||
help | ||
fi | ||
|
||
# Charger les identifiants à exclure dans un tableau | ||
mapfile -t exclude_ids < "$exclude_ids_file" | ||
|
||
temp_path="/QRISdata/Q7361/temp" | ||
|
||
# Assurez-vous que le répertoire temporaire existe | ||
mkdir -p "$temp_path" | ||
|
||
# Lire chaque ligne du fichier fastq_ids.txt | ||
while read -r srr_id; do | ||
# Vérifier si l'identifiant est dans la liste des exclusions | ||
if printf '%s\n' "${exclude_ids[@]}" | grep -qx "$srr_id"; then | ||
echo "Skipping excluded ID: $srr_id" | ||
continue | ||
fi | ||
echo "Téléchargement et conversion de $srr_id en format fastq depuis NCBI..." | ||
# Télécharger et convertir le fichier SRA en fichiers fastq | ||
mkdir -p "$outputpath/$srr_id" | ||
fasterq-dump --ngc "$keypath" --split-files "$srr_id" -O "$outputpath/$srr_id" --temp "$temp_path" | ||
done < "$fastq_ids_file" | ||
|
||
echo "download over" |
Oops, something went wrong.