#!/bin/bash
# csv2pcd.sh csvfile pcdfile
# This script partly automates creation of PCD code for use by WebLogo specifying custom color schemes.
# Input files can be created by reading .csv files from the blpalign/seqcolors directory into
# a spreadsheet.

#aa	colour
#ILVAM	#ffafaf
#FWY	#ffc800
#KRH	#6464ff
#DE	#ff0000
#STNQ	#00ff00
#PG	#ff00ff
#C	#ffff00

# The steps to modify the file is as follows:
# 1. Save file as a .csv file in the working directory
# 2. Delete title line
# 3. Swap Columns 1 and 2
# 4. Do a global replace of '#' with '\#'
# 5. Copy the amino acid column to column 4
# 6. Put single quotes (') into each cell of columns 3 and 5
# 7. Save the file
# 8. csv2pcd.sh csvfile pcdfile
#
# The contents of the pcdfile can now be pasted into a the color scheme combobox in blpalign.blmenu


cat $1 | sed -e "s%^%-C\t%" |  sed -e "s%'\t%'%" | sed -e "s%\t'$%'%" | tr -s '\t' ' ' | tr '\n' ' ' > $2
