#*/
#* Copyright (c) 2011 Gitanjali Yadav (gy@nipgr.res.in)
#* All rights reserved.
#*
#* Redistribution and use in source and binary forms, with or without
#* modification, are permitted without a fee provided that the following
#* conditions are met:
#*
#* 1. This software is only used for private, research, or academic 
#*    purposes.
#*    
#* 2. Redistributions of source code must retain the above copyright
#*    notice, this list of conditions and the following disclaimer.
#*
#* 3. Redistributions in binary form must reproduce the above copyright
#*    notice, this list of conditions and the following disclaimer in the
#*    documentation and/or other materials provided with the distribution.
#*
#* 4. Any changes made to this package must be submitted to the author.
#*    The legal status of the submitted changes must allow their inclusion
#*    into this package under this license.
#*
#* 5. Publications in the field of pseudorandom number generation, which
#*    made use of this package must include a reference to this package.
#*      
#* Any use of this software in a commercial environment requires a
#* written licence from the author. Contact Gitanjali Yadav
#* (gy@nipgr.res.in) to negotiate the terms.
#*
#* THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
#* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
#* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#* 
#* IN NO EVENT SHALL GITANJALI YADAV BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
#* INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES 
#* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR
#* NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF 
#* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 
#* OF THIS SOFTWARE.
#*
#*/
#*
#*/
#*  get_perturbation_network 	Induction & analysis of single node perturbation 
#*
#*  Author:	Gitanjali Yadav (gy@nipgr.res.in)
#*
#*  Last Modification: Wed Sep 18 12:50:35 CEST 2011
#*
#*  Called from within 'run_cascades' 
#*  for each successive perturbation in the sequence
#*/

#*/ Modification History:

#   11/01/01: First Version.
#*/

echo $2 >isno
echo $1 >ispname
grep -w "`echo $1`" itotal_extinct >imissing
if test -s imissing
then
echo $1 is ALREADY EXTINCT! SKIPPING THIS ONE.
else
echo $1 $2 >>iprimary_extinctions
wc -l iprimary_extinctions | awk '{print $1}' >iprimary
head -`cat iprimary` serial_number | tail -1 >ipri_ext
grep -wv "`echo $1`" inetwork_new >inewnet
wc -l inewnet | awk '{print $1}' >iremaining_int
echo DATA_`cat itype_id`_`cat isp_id`_`cat ipri_ext`.ncol >ifilename
cp inewnet `cat ifilename`
expr `cat total_int` - `cat iremaining_int` >ilost_int
rm -f iextinct_list
./get_total_extinction_ALL
wc -l iextinct_list | awk '{print $1}' >iextinct_num
cp iextinct_list itotal_extinct
expr `cat iextinct_num` - `cat iprimary` >isec_ext
expr `cat total_sp` - `cat iextinct_num` > inet_size
mv iextinct_list `cat ifilename`.extinct
cat ifilename isno  iprimary iextinct_num isec_ext inet_size iremaining_int ilost_int ispname >itmp
paste -s itmp
mv inewnet inetwork_new
fi
