Skip to content

Instantly share code, notes, and snippets.

@icaoberg
Created April 4, 2013 18:36
Show Gist options
  • Save icaoberg/5312936 to your computer and use it in GitHub Desktop.
Save icaoberg/5312936 to your computer and use it in GitHub Desktop.
[Human Protein Atlas] Helper script that downloads images from the database given a file with accession ids
#!/bin/bash
# Author: Ivan E. Cao-Berg (icaoberg@scs.cmu.edu)
#
# Copyright (C) 2013 Murphy Lab
# Lane Center for Computational Biology
# School of Computer Science
# Carnegie Mellon University
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published
# by the Free Software Foundation; either version 2 of the License,
# or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
#
# For additional information visit http://murphylab.web.cmu.edu or
# send email to murphy@cmu.edu
if [ $# -eq 0 ]; then
echo "Usage:"
echo "bash ./getdata links_file.txt"
echo "No arguments supplied. Exiting script"
exit
fi
FILELIST=$1
for ID in $(cat $FILELIST)
do
echo $ID
wget -q --output-document $ID.html http://www.proteinatlas.org/$ID
if [ ! -d $ID ]; then
mkdir $ID
fi
echo $TEMP > temp
awk '/HPA/{for(i=1;i<=NF;i++)print $i}' temp >> images
rm temp
sed 's/,//' images > temp
mv temp images
for LINE in $(cat images)
do
if [ ! -z $LINE ]; then
mkdir ./$ID/$LINE
wget -qnc --output-document ./$ID/$LINE/fluo.jpg http://www.proteinatlas.org/images/${LINE#HPA0}/if_selected.jpg
wget -qnc --output-document ./$ID/$LINE/ihc.jpg http://www.proteinatlas.org/images/${LINE#HPA0}/ihc_selected.jpg
fi
done
rm $ID.html
rm images
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment