A first functionnal version of the normalize_plastid.sh script.
Former-commit-id: 78c4a4d8497e6dc7185a6e5726ffc643d9ea914d Former-commit-id: e6945818dbdbabd9cd060edb9d2578ea26671209
This commit is contained in:
@ -62,10 +62,58 @@ function logwarning {
|
||||
|
||||
# Sequence related functions
|
||||
|
||||
# Counts how many sequences are stored in a fasta file
|
||||
# - $1 : The fasta file to count
|
||||
function fastaCount {
|
||||
grep '^>' $1 | wc -l
|
||||
}
|
||||
|
||||
|
||||
# compute the sequence length from a fasta sequence
|
||||
# - $1 : The fasta file to cut
|
||||
function seqlength {
|
||||
cat $1 | \
|
||||
wc |\
|
||||
awk -v t="`head -1 $1 | wc -c`" '{print $3 - t - $1 + 1}'
|
||||
}
|
||||
|
||||
# extract a subseq from a fasta sequence
|
||||
# - $1 : The fasta file to cut
|
||||
# - $2 : First position of the subsequence (first position is numered 1),
|
||||
# - $3 : End of the subsequence (included in the subsequence)
|
||||
function cutseq {
|
||||
awk -v from=$2 -v end=$3 'function printfasta(seq) { \
|
||||
seqlen=length(seq); \
|
||||
for (i=1; i <= seqlen; i+=60) \
|
||||
print substr(seq,i,60); \
|
||||
} \
|
||||
\
|
||||
/^>/ {print $0} \
|
||||
! /^>/ {seq=seq$0} \
|
||||
END {printfasta(substr(seq,from,end-from+1))}' $1
|
||||
}
|
||||
|
||||
# Joins a set of sequences stored in a fasta file into
|
||||
# a single sequence
|
||||
# - $1 : The fasta file containing the sequences to join
|
||||
function joinfasta {
|
||||
awk '(NR==1 && /^>/) {print $0} \
|
||||
! /^>/ {print $0}' $1 | \
|
||||
formatfasta
|
||||
}
|
||||
|
||||
function formatfasta {
|
||||
awk 'function printfasta(seq) { \
|
||||
seqlen=length(seq); \
|
||||
for (i=1; i <= seqlen; i+=60) \
|
||||
print substr(seq,i,60); \
|
||||
} \
|
||||
/^>/ { print $0 } \
|
||||
! /^>/ { seq=seq $0 } \
|
||||
END { printfasta(seq)}' $1
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
#
|
||||
########################
|
||||
@ -115,3 +163,4 @@ export PATH
|
||||
export LANG=C
|
||||
export LC_ALL=C
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user