#!/usr/bin/perl # Test code for hash use Data::Random qw(:all); use List::Util qw(shuffle); # Read in two files containing Rgroups into 2 arrays unless ( open (A1_FILE, "A1.txt")) { print "Cannot find A1 list\n\n"; exit } unless ( open (A2_FILE, "A2.txt")) { print "Cannot find A2 list \n\n"; exit } my @A1 = ; chomp (@A1); close (A1_FILE); my @A2 = ; chomp (@A2); close (A2_FILE); my @A1_shuffled = shuffle (@A1); my @A2_shuffled = shuffle (@A2); print "\nEnter the name of the output file(give full path): "; my $outfile = ; chomp $outfile; open (OUTPUT, ">$outfile"); print "\nEnter the number of ligands needed: "; my $size = ; chomp $size; print "\nEnter the scaffold name: "; my $scaffold = ; chomp $scaffold; my %ligands = (); for ($i=0; $i<$size; $i++) { my @random_A1 = rand_set( set => \@A1_shuffled, size => 1 ); my @random_A2 = rand_set( set => \@A2_shuffled, size => 1); $ligands{$ligand}=$i; } my $keys = keys(%ligands); my @temp = keys(%ligands); for ($z=0; $z<$keys; $z++){ print OUTPUT @temp[$z]; print OUTPUT "\n"; } close OUTPUT; print "\n"; print "\nSize of hash: ". keys(%ligands) . ".\n"; exit