#!/bin/csh -f
# localuse not for download
# master.csh
#source /nfs/soft/jchem/current/env.csh
source /nfs/soft/mitools/env.csh
source /nfs/soft/www/apps/zinc15/envs/edge/env.csh
setenv ZINC_CONFIG_ENV admin
setenv ZINC_CONFIG_SETUP_SKIP blueprints

cd /nfs/db/export/catalogs/

setenv i $1
mkdir -p $i
cd $i
#psql -h mem -U test zinc15 -c "select short_name from catalog where purchasable = $i order by original_size" -t -F '\t' -o list
foreach j ($2)
	if (-d "$j.d") /bin/rm -rf $j.d
	mkdir $j.d
	pushd $j.d
	~/bin/fetchVendorC.py $j > $j.info.txt
	mkdir lead-like
	pushd lead-like
	/nfs/db/export/catalogs/getme.csh  $j "C D E"
	popd
	mkdir frag-like
	pushd frag-like
	/nfs/db/export/catalogs/getme.csh  $j "A B"
	popd

	#~/bin/fetchVendorP.py $j > $j.3d.txt
	#~/bin/fetchVendorS.py $j > $j.2d.txt
	popd
	if (-d $j) then
		mv $j $j.old
	endif
	mv $j.d $j
	gzip -9 $j/*.txt & 
end
