forked from CRG-Beato/utils_beatolab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
extract_transcripts_sequences.sh
executable file
·78 lines (63 loc) · 2.24 KB
/
extract_transcripts_sequences.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/bin/bash
#==================================================================================================
# Created on: 2015-12-22
# Usage: ./extract_transcripts_sequences.sh
# Author: javier.quilez@crg.eu
# Goal: uses GTF file (with genomic coordinates) to extract transcript sequences in FASTA
#==================================================================================================
#==================================================================================================
# CONFIGURATION VARIABLES AND PATHS
#==================================================================================================
# Variables
process="extract_transcripts_sequences"
species="homo_sapiens"
version="hg19"
# Paths
transcripts=$HOME/assemblies/$species/$version/gencode/gencode.v19.annotation
genome_fasta=$HOME/assemblies/$species/$version/ucsc/$version.fa
transcript_fasta=
JOB_CMD=$HOME/utils/job_cmd
JOB_OUT=$HOME/utils/job_out
TMP_DIR=$HOME/utils/tmp_dir
mkdir -p $JOB_CMD
mkdir -p $JOB_OUT
mkdir -p $TMP_DIR
gtf2bed=`which gtf2bed`
bedtools=`which bedtools`
# CRG cluster parameters
queue=short-sl65
memory=10G
max_time=06:00:00
slots=1
#==================================================================================================
# JOB
#==================================================================================================
# Build job: parameters
job_name=${process}_${species}_${version}
job_file=$JOB_CMD/$job_name.sh
m_out=$JOB_OUT
echo "#!/bin/bash
#$ -N $job_name
#$ -q $queue
#$ -l virtual_free=$memory
#$ -l h_rt=$max_time
#$ -M javier.quilez@crg.eu
#$ -m abe
#$ -o $m_out/${job_name}_\$JOB_ID.out
#$ -e $m_out/${job_name}_\$JOB_ID.err
#$ -pe smp $slots" > $job_file
# convert GTF to BED12
tbed=$TMP_DIR/tmp_gencode.v19.annotation.bed
job_cmd="$gtf2bed -r $TMP_DIR < <(grep -P '\ttranscript\t' $transcripts.gtf | grep -vP '^chrY' | grep -vP '^chrM') > $tbed"
echo $job_cmd >> $job_file
# extract FASTA from BED12 and compress
ofa=$transcripts.fa
job_cmd="$bedtools getfasta -fi $genome_fasta -bed $tbed -split -name -fo $ofa"
echo $job_cmd >> $job_file
job_cmd="gzip -f $ofa"
echo $job_cmd >> $job_file
# remove temporary directory
echo "rm -fr $TMP_DIR" >> $job_file
# Submit job
chmod a+x $job_file
qsub < $job_file