-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwrap_fasta.sh
More file actions
executable file
·47 lines (43 loc) · 1.07 KB
/
wrap_fasta.sh
File metadata and controls
executable file
·47 lines (43 loc) · 1.07 KB
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
#!/bin/bash
# provide the input fasta file and the name of the output fasta file.
# e.g. join_fasta.sh input.faa output.fasta
# will join all lines of amino acids into one line. will not join lines starting with >
input_fasta="$1"
# output_fasta="$2"
awk '/^>/ { if(NR==1) {print $0;} else {printf "\n%s\n",$0;} next; } { printf "%s",$0 }' $input_fasta
# Check if the input file is provided
# if [ -z "$1" ]; then
# echo "Usage: $0 input.fasta output.fasta"
# exit 1
# fi
#
# input_file="$1"
# output_file="$2"
#
# awk '
# BEGIN {
# # Initialize an empty sequence string
# seq = ""
# }
# /^>/ {
# # Print the previous sequence if not empty
# if (seq != "") {
# print seq > output_file
# }
# # Print the header
# print $0 > output_file
# # Reset the sequence string
# seq = ""
# }
# /^[^>]/ {
# # Append the sequence line to the sequence string
# seq = seq $0
# }
# END {
# # Print the last sequence
# if (seq != "") {
# print seq > output_file
# }
# }
# ' output_file="$output_file" "$input_file"
#