Created
April 14, 2015 08:45
-
-
Save mgalardini/0335af7bc757af7310ad to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Copyright (C) <2015> EMBL-European Bioinformatics Institute | |
# 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 3 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. | |
# Neither the institution name nor the name get_kegg_modules can | |
# be used to endorse or promote products derived from this | |
# software without prior written permission. For written | |
# permission, please contact <[email protected]>. | |
# Products derived from this software may not be called | |
# get_kegg_modules nor may get_kegg_modules appear in their names | |
# without prior written permission of the developers. | |
# You should have received a copy of the GNU General Public | |
# License along with this program. If not, see | |
# <http://www.gnu.org/licenses/>. | |
if [ "$#" -lt 1 ]; then | |
echo 'get_kegg_modules KEGG_ORG' | |
exit 65 | |
fi | |
KEGG_ORG=$1 | |
# Get modules | |
wget --quiet -O modules.txt "http://rest.kegg.jp/list/module/$KEGG_ORG" | |
# For each module retrieve the genes | |
for module in $(awk '{print $1}' modules.txt) | |
do | |
wget --quiet -O $(echo $module | awk -F ':' '{print $2}').txt "http://rest.kegg.jp/link/$KEGG_ORG/$module"; | |
for gene in $(awk -F '\t' '{print $2}' $(echo $module | awk -F ':' '{print $2}').txt | awk -F ':' '{print $2}') | |
do | |
echo -e "$gene\t$(echo $module | awk -F ':' '{print $2}')"; | |
done; | |
rm $(echo $module | awk -F ':' '{print $2}').txt; | |
done | |
# Clean | |
rm modules.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment