# Read your input alignment and generate a
# tmp FASTA file
count=0
while read -r line
do
count=$(( count + 1))
new_line=$(echo $line )
if [[ $line =~ "_" ]]
then
new_line=$( echo $new_line | sed 's/^/\>/' )
fi
if [[ $count -eq 1 ]]
then
echo $new_line > aln.fasta
else
echo $new_line >> aln.fasta
fi
done < Ga_supertree_467_taxa_DNA_clustalo_backtrans.phy
# Get rid of the PHYLIP header and the second
# blank line and carriage characters
sed -i 's/\r//g' aln.fasta
sed -i '1,2d' aln.fasta
# Give first permissions to all my perl scripts
# in case you have not done so
chmod 775 *pl
# Call my perl script to format the FASTA
# file so that there is one line per sequence
# Remove first FASTA file and rename new
# one-line FASTA file
rm aln.fasta
mv aln_one_line.fa aln.fasta
# Get the number of taxa and length of
# sequence and run my script to convert
# the FASTA file into PHYLIP format
aln_name=`ls *.fasta`
a_noext=$( echo $aln_name | sed 's/\.fasta//' )
num=$( grep '>' $aln_name | wc -l )
len=$( sed -n '2,2p' $aln_name | sed 's/\r//' | sed 's/\n//' | wc --m )
perl FASTAtoPHYL.pl $aln_name $num $len
# Remove files that are no longer required
# to save space
rm aln.fasta log_lenseq.txt