#!/usr/bin/perl use strict; use ProbeSearch; use constant SUCCESS => 0; use constant ERROR => -1; require XML::Simple; use subs ; use Data::Dumper; sub get_targets { my $targets; while ( $targets eq "" ) { print "Which Target(s), All, or Quit (ex: 1 1,2 all) : "; chop($targets = ); exit if ($targets =~ m/^ *[Qq]uit *$/); # Convert "All" to list of targets $targets = "1,2,3,4,5" if ($targets =~ m/^ *[Aa]ll *$/); if (!($targets =~ m/^ *[0-9](,\d)* *$/)) { print "$targets: Not a valid target list\n "; $targets=""; } } return $targets; } sub get_location { my $start; while ( $start eq "" ) { print "Starting Basepair : "; chop($start= ); exit if ($start =~ m/^ *[Qq]uit *$/); # Convert "All" to list of targets $start= "all" if ($start=~ m/^ *[Aa]ll *$/); if (!($start =~ m/^ *[0-9]+ *$/)) { print "$start : Not a valid target list\n "; $start =""; } } return $start; } sub get_species { my $species; while ( $species eq "" ) { print "Species List\n"; print "============\n"; print " 1. Mouse\n"; print " 2. Baboon\n"; print " 3. Cat\n"; print " 4. Chicken\n"; print " 5. Chimp\n"; print " 6. Cow\n"; print " 7. Dog\n"; print " 8. Fugu\n"; print " 9. Pig\n"; print " 10. Rat\n"; print " 11. Tetra\n"; print " 12. Zebra Fish\n\n"; print "Which Species(s), All, or Quit (ex: 1 1,2 all) : "; chop($species= ); exit if ($species=~ m/^ *[Qq]uit *$/); # Convert "All" to list of targets $species = "1,2,3,4,5,6,7,8,9,10,11,12" if ($species =~ m/^ *[Aa]ll *$/); if (!($species =~ m/^ *[0-9](,\d)* *$/)) { print "Sspecies : Not a valid target list\n "; $species = ""; } } return $species; } sub select_probes { my $species; my $target; my $start; my $end; my $file; ($species, $target, $start, $end) = (@_); $file = "/home/bcarlson/data/"; $file .= "Target$target/"; $file .= "human_".$species."_T".$target.".verbose.probes.xml"; my $xs = new XML::Simple(); my $probe_analysis= $xs->XMLin($file); for (my $i=0; $i<@{$probe_analysis->{parent_alignment}}; $i++) { if (($start <= $probe_analysis->{parent_alignment}->[$i]->{species}->{species1}->{start}) && ($end >= $probe_analysis->{parent_alignment}->[$i]->{species}->{species1}->{end})) { print "SELECT : "; print "[$species] "; print "[".$probe_analysis->{parent_alignment}->[$i]->{probe}->{sequence}."] "; print "[".$probe_analysis->{parent_alignment}->[$i]->{species}->{species1}->{start}."] "; print "[".$probe_analysis->{parent_alignment}->[$i]->{species}->{species1}->{end}."]\n"; print "\n"; } #else #{ print "IGNORE : "; } #print "Probe End [".$probe_analysis->{parent_alignment}->[$i]->{species}->{species1}->{end}."]\n"; #print "[$species] "; #print "[".$probe_analysis->{parent_alignment}->[$i]->{probe}->{sequence}."] "; #print "[".$probe_analysis->{parent_alignment}->[$i]->{species}->{species1}->{start}."] "; #print "[".$probe_analysis->{parent_alignment}->[$i]->{species}->{species1}->{end}."]\n"; #print "\n"; } } sub getParams { my %opts; my $errstr = ""; use Getopt::Long; GetOptions(\%opts, 'help'); if (defined($opts{help})) { $errstr = "\n"; } if ($errstr) { print <<"END_USAGE"; Description: This script will take a species, target and bp range and return all the probes in that range. Currently everything is hard coded. Usage: select_probes.pl END_USAGE print "\n$errstr" if ($errstr); die("\n"); } } #my $species = get_species(); #my $targets = get_targets(); print "PROCESSING TARGET 3\n"; select_probes "cat",3,1850000,2850000; select_probes "chicken",3,1850000,2850000; select_probes "cow",3,1850000,2850000; select_probes "dog",3,1850000,2850000; select_probes "fugu",3,1850000,2850000; select_probes "mouse",3,1850000,2850000; select_probes "pig",3,1850000,2850000; select_probes "rat",3,1850000,2850000; select_probes "tetraodon",3,1850000,2850000; select_probes "zfish",3,1850000,2850000; print "PROCESSING TARGET 5\n"; select_probes "cat",5,2000000,27500000; select_probes "cow",5,2000000,27500000; select_probes "dog",5,2000000,27500000; select_probes "mouse",5,2000000,27500000; select_probes "pig",5,2000000,27500000; select_probes "rat",5,2000000,27500000; select_probes "zfish",5,2000000,27500000; #print "Processing species [$species]\n"; #print "For Targets [$targets]\n";