#!/usr/bin/perl -w # Sun Feb 3 12:17:30 PST 2008 Kevin Karplus # make_all_templates_under # --target XXX0000 # < TARGET.best-scores.rdb # > all-templates.under # generates a script for undertaker to use in extracting contacts # from the alignments. The target name must be supplied. # # The script is NOT a complete undertaker script---it contains only # the ReadFragmentAlignment commands to read in the a2m files. # Setting up the target, selecting the training chains to use for # a generic fragment library, selecting a clash definition, ... # all must be done first, before doing an Include command to read # in the fragments. # OPTIONS: # --target TARGETNAME required to specify name of target sequence # # --type t06-local-str2+near-backbone-11-0.8+0.6+0.8-adpstyle5.a2m # specifies which alignment style to include # May be repeated to get multiple types. # # --backup t06-local-adpstyle5.a2m # specifies which alignment style to include, if the # preferred type is missing. # # --min_num 10 Minimum number of templates to include # # --max_evalue 10.0 Maximum e-value to include # # If there have been min_num alignments already output, and the # e_value is bigger than max_evalue, then this template is omitted. # # STANDARD IN: # the input should be an rdb file with containing columns # Sequence_ID and Evalue # sorted in increasing order of Evalue. # BUGS: # no usage message, little error checking. # CHANGE LOG: # Sun Apr 6 10:22:30 PDT 2008 Kevin Karplus # changed --type to be used repeatedly, defaulting to t2k, t04, and t06 alignments # Sun Apr 6 10:46:43 PDT 2008 Kevin Karplus # changed to have a minimum of 10 templates (instead of 20 alignments) use strict; use Getopt::Long; my $target; my @alignment_types; my $backup_alignment_type = "t06-local-adpstyle5.a2m"; my $min_num = 10; my $max_evalue = 10.0; GetOptions( "target=s" => \$target , "type=s" => \@alignment_types , "backup=s" => \$backup_alignment_type , "min_num=n" => \$min_num , "max_evalue=f" => \$max_evalue ); if (!defined($target)) { die "ERROR: make_all_templates_under requires a --target argument\n"; } if (scalar(@alignment_types)==0) { push @alignment_types, "t06-local-str2+near-backbone-11-0.8+0.6+0.8-adpstyle5.a2m"; push @alignment_types, "t04-local-str2+near-backbone-11-0.8+0.6+0.8-adpstyle5.a2m"; push @alignment_types, "t2k-local-str2+near-backbone-11-0.8+0.6+0.8-adpstyle5.a2m"; } # skip comments at beginning of rdb file for ($_=; /^\s*#/; $_=) {} # now get the column names chomp; my @col_names = split(/\t/); # names for the colummns my %col_num; for (my $i=0; $i < scalar(@col_names); $i++) { $col_num{$col_names[$i]} = $i; } my $id_num = $col_num{"Sequence_ID"}; my $eval_num = $col_num{"Evalue"}; if (!defined($id_num) || !defined($eval_num)) { die "ERROR: make_all_templates_under can't find SequenceID and Evalue columns\n"; } ; # skip a line (the N and S rdb line) my $num_aligns=0; my $num_templates=0; while () { chomp; my @cols = split(/\t/); next if scalar(@cols) <= $id_num; next if scalar(@cols) <= $eval_num; my $evalue = $cols[$eval_num]; # print STDERR "DEBUG: e_value $evalue\n"; next if ($num_templates>= $min_num && $evalue > $max_evalue); my $before_align = $num_aligns; my $id = $cols[$id_num]; for my $alignment_type (@alignment_types) { my $align_name = "$id/$id-$target-$alignment_type"; if (-e $align_name) { print "ReadFragmentAlignment $align_name NOFILTER force_alignment e_value $evalue\n"; $num_aligns ++; } $align_name = "$id/$target-$id-$alignment_type"; if (-e $align_name) { print "ReadFragmentAlignment $align_name NOFILTER force_alignment e_value $cols[$eval_num]\n"; $num_aligns ++; } } if ($before_align == $num_aligns) { # didn't find any of the three-track alignments I expected. Look for a single-track alignment. my $align_name = "$id/$target-$id-$backup_alignment_type"; if (-e $align_name) { print "ReadFragmentAlignment $align_name NOFILTER force_alignment e_value $cols[$eval_num]\n"; $num_aligns ++; } } $num_templates++ if ($before_align < $num_aligns); } die "ERROR: make_all_templates_under found no alignments\n" if ($num_aligns==0); print STDERR "make_all_templates_under found $num_aligns alignments\n";