CSC212 Tcsh script for processing DNA files

From dftwiki3
Jump to: navigation, search

--D. Thiebaut (talk) 11:25, 16 October 2014 (EDT)


findDNA.sh


The script below can be created with emacs, and must be made executable before running it, as follows:

chmod +x findDNA.sh


#! /bin/tcsh
# findDNA.sh
# D. Thiebaut
# Demo script for tcsh lecture, CSC212
#

# URL where DNA files are residing
set url=http://cs.smith.edu/~212a/DNAFiles

# pattern to search in DNA files
set pattern=CGTGACTCAA

# download all files DNA_000x where x is 0 to 9
foreach n ( `seq 0 9` )
   wget -q $url/DNA_000$n.txt
end

# download all files DNA_00x where x is 10 to 99
foreach n ( `seq 10 99` )
   wget -q $url/DNA_00$n.txt
end

# count number of files downloaded
set num=`ls DNA* | wc -l`
echo "Downloaded $num DNA files"

# identify files containing pattern and save to file
grep -l $pattern DNA* >! $pattern.txt

# remove all DNA files
unalias rm
rm DNA_*