#!/usr/bin/perl -w 
#
#for a given molecule, figure out what the best way of buying it is. 
#
#
# for example CHEMBL3754098 (what target is it good for)
#
#
# another question is, for a given gene, which molecules can I buy, exact match.
#
#
#find . -name '*CHEMBL3754098*' -print > tmp
#
#now we parse tmp and we figure out the best way to buy it. or its analogs.  
#

#tmp contains all the molecule - purch database pairs that hit
#tmp.0-4 contain actual hits inside those databases
##
open (FOO, "<tmp"); 
while (<FOO>) {
	my $l = $_;
	chomp $l;
	next unless /.txt$/;
	#print "$l\n";
	my @ll = split(/\//,$l);
	print "$ll[3] gene ";  # gene
	print "$ll[4] purch class ";  # purch class
	my $cat = $ll[5];
	$cat =~ s/CHEMBL[0-9]*.//;
	$cat =~ s/.txt$//;
	print "$cat cat info \n";  # catalog info 

	# now we need to open it and parse it. 
	# we know tmp.* are present. 
}


# so the logic goes:  are there any exact matches for this compound? show them.  ordered by database priority
# progressively show the less similar, again ordered by database similarity. 
#
#
