This file is indexed.

/usr/lib/ChimeraSlayer/PerlLib/AlignCompare.pm is in chimeraslayer 20101212+dfsg-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
package AlignCompare;

use strict;
use warnings;
use Carp qw (cluck confess);
use List::Util qw (min max);


## In all methods below, non-GATC characters do not count as valid bases ##


sub compute_per_ID {
	my ($seqA, $seqB) = @_;


	if (length($seqA) != length($seqB)) {
		confess "Error, cannot compute perID for nonidentical sequence lengths";
	}
	
	my @charsA = split(//, uc $seqA);
	my @charsB = split(//, uc $seqB);
        
	
	my ($lendBoundA, $rendBoundA) = &find_ends_of_alignment(@charsA);
	my ($lendBoundB, $rendBoundB) = &find_ends_of_alignment(@charsB);

	my $lend_bound = max($lendBoundA, $lendBoundB);
	my $rend_bound = min($rendBoundA, $rendBoundB);
	

	my $same_chars = 0;
	my $chars_in_A = 0;
	my $chars_in_B = 0;
	

	for (my $i = $lend_bound; $i <= $rend_bound; $i++) {
		my $charA = $charsA[$i];
		my $charB = $charsB[$i];
		
		## If character is not recognized, it's completely ignored.
		if ($charA !~ /[GATC\.\-]/i || $charB !~ /[GATC\.\-]/i ) { next; }
		
		my $charA_GATC = ($charA =~ /[GATC]/) ? 1:0;
		my $charB_GATC = ($charB =~ /[GATC]/) ? 1:0;
		
		if ($charA_GATC || $charB_GATC)  {
						
			if ($charA_GATC) {
				$chars_in_A++;
			}
			if ($charB_GATC) {
				$chars_in_B++;
			}
			
			if ($charA eq $charB) {
				$same_chars++;
			}
		}
	}
	
	## total number of chars in alignment is taken as the average of the two sequence lengths.
	my $num_chars = ($chars_in_A + $chars_in_B) / 2;

	if ($num_chars == 0) {
	    cluck "Warning, no base characters in either A or B sequences";
		return(0);
	}
	
	return($same_chars/$num_chars * 100);
	
}

####
sub find_lend_match {
	my ($charsA_aref, $charsB_aref) = @_;

	for (my $i = 0; $i <= $#$charsA_aref; $i++) {
		if ($charsA_aref->[$i] =~ /[GATC]/i && $charsB_aref->[$i] =~ /[GATC]/i) {
			return($i);
		}
	}
        
	return(0);  # default is start at beginning
}

####
sub find_rend_match {
	my ($charsA_aref, $charsB_aref) = @_;

	for (my $i = $#$charsA_aref; $i >= 0; $i--) {
		if ($charsA_aref->[$i] =~ /[GATC]/i && $charsB_aref->[$i] =~ /[GATC]/i) {
			return($i);
		}
	}
        
	return($#$charsA_aref);  # default is stop at end
}

####
sub define_left_clip {
	my ($chars_aref, $start, $length) = @_;
	
	my $count = 0;
	for (my $i = $start; $i >= 0; $i--) {
		my $char = $chars_aref->[$i];
		if ($char =~ /\w/) {
			$count++;
			if ($count >= $length) {
				return($i);
			}
		}
	}
	
	confess "Error, couldn't define a left clip position";
}

####
sub define_right_clip {
	my ($chars_aref, $start, $length) = @_;

	my $count = 0;
	for (my $j = $start; $j <= $#$chars_aref; $j++) {
		my $char = $chars_aref->[$j];
		if ($char =~ /\w/i) {
			$count++;
			if ($count >= $length) {
				return($j);
			}
		}
	}
	
	confess ("Error, cannot define a right clip position");
}



####
sub find_ends_of_alignment {
	my @align_array = @_;
		
	my $index_left;
	my $index_right;

	for (my $i = 0; $i <= $#align_array; $i++) {
		if ($align_array[$i] =~ /[GATC]/i) {
			$index_left = $i;
			last;
		}
	}

	for (my $i = $#align_array; $i >= 0; $i--) {
		if ($align_array[$i] =~ /[GATC]/i) {
			$index_right = $i;
			last;
		}
	}
	
	return($index_left, $index_right);
}



1; #EOM