/usr/share/art-nextgen-simulation-tools/ART_profiler_illumina/empDist.pl is in art-nextgen-simulation-tools-profiles 20160605+dfsg-2build1.
This file is owned by root:root, with mode 0o755.
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 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 | #!/usr/bin/perl
# A perl program to create an empirical distribution from a frequency file
# generated by the summation.pl program and modified by the combinedAvg.pl
# program.
#
# @author Jason Myers
# Date: July 2, 2010
use strict;
# Print an error message unless the atleast two fastqReadAvg files and an output file are specified
my $numArgs = $#ARGV + 1;
unless( $numArgs == 2){
print "Usage: perl empDist.pl freqFile outputFile \n";
exit;
}
# Possible nucleotidees
my @NUCLEO = ('.', 'A', 'T', 'G', 'C', 'N');
# Arrays specific to each nucleotide
my @DATA_ALL = ();
my @DATA_A = ();
my @DATA_T = ();
my @DATA_G = ();
my @DATA_C = ();
my @DATA_N = ();
# Total variables associated to each nucleotide
my $allTot = 0;
my $aTot = 0;
my $tTot = 0;
my $gTot = 0;
my $cTot = 0;
my $nTot = 0;
# Open the file in question
my $infile = $ARGV[0];
open INFILE, "$infile", or die $!;
my $count = 0;
# An array to temporarily store each files frequency lines
my @TEMP = ();
# A variable to hold the initial grab of the current line
my $line = '';
# variable corresponding to the current length
my $curLength;
# all possible quality scores
my @SCORES = ();
for(my $t = 0; $t < 71; $t++){
$SCORES[$t] = $t;
}
# Set the line counter to 0
# Loop over each line of the file
while(<INFILE>){
if( $count >= 1 && $count <= 72 ){
# get the line
$line = $_;
# split the line up into its elements
@TEMP = split('\t', $line);
# determine the current length being dealt with
$curLength = $#TEMP / 5;
# which nucleotide is being dealt with
my $flag = 0;
# which position of the read is being dealt with
my $position = 0;
# loop over the current line
foreach my $pos(0 .. $#TEMP){
# Distribute the frequency values to their respective arrays
if($flag == 0){
$DATA_ALL[$count - 1][$position] += $TEMP[$pos];
$DATA_A[$count - 1][$position] = $TEMP[$pos];
} elsif($flag == 1){
$DATA_ALL[$count - 1][$position] += $TEMP[$pos];
$DATA_T[$count - 1][$position] = $TEMP[$pos];
} elsif($flag == 2){
$DATA_ALL[$count - 1][$position] += $TEMP[$pos];
$DATA_G[$count - 1][$position] = $TEMP[$pos];
} elsif($flag == 3){
$DATA_ALL[$count - 1][$position] += $TEMP[$pos];
$DATA_C[$count - 1][$position] = $TEMP[$pos];
} elsif($flag == 4){
$DATA_ALL[$count - 1][$position] += $TEMP[$pos];
$DATA_N[$count - 1][$position] = $TEMP[$pos];
}
$position++;
# if the position being dealt with is the length of the read
if($position == $curLength){
# move to the next possible nucleotide
$flag++;
# reset the position to 0
$position = 0;
}
}
# set the temp variable back to null
@TEMP = ();
}
# increase the line counter
$count++;
}
# close the current infile
close(INFILE);
# open the outfile
my $outfile = $ARGV[$numArgs - 1];
open OUTFILE, ">>$outfile", or die $!;
# loop over the possible nucleotides
for(my $nuc = 0; $nuc < 6; $nuc++){
#loop over the possible positions
for(my $pos = 0; $pos < $curLength; $pos++){
print OUTFILE $NUCLEO[$nuc], "\t", $pos, "\t";
# loop over the possible quality scores
for(my $qual = 0; $qual < 71; $qual++){
# determine the quality scores that have non-zero frequencies
if($nuc == 0){
unless($DATA_ALL[$qual][$pos] == 0){
print OUTFILE $SCORES[$qual], "\t";
}
} elsif($nuc == 1){
unless($DATA_A[$qual][$pos] == 0){
print OUTFILE $SCORES[$qual], "\t";
}
} elsif($nuc == 2){
unless($DATA_T[$qual][$pos] == 0){
print OUTFILE $SCORES[$qual], "\t";
}
} elsif($nuc == 3){
unless($DATA_G[$qual][$pos] == 0){
print OUTFILE $SCORES[$qual], "\t";
}
} elsif($nuc == 4){
unless($DATA_C[$qual][$pos] == 0){
print OUTFILE $SCORES[$qual], "\t";
}
} elsif($nuc == 5){
unless($DATA_N[$qual][$pos] == 0){
print OUTFILE $SCORES[$qual], "\t";
}
}
}
print OUTFILE "\n", $NUCLEO[$nuc], "\t", $pos, "\t";
# loop over the quality scores again
for(my $qual = 0; $qual < 71; $qual++){
# display the cumulative frequency for each quality score
if($nuc == 0){
unless($DATA_ALL[$qual][$pos] == 0){
$allTot += $DATA_ALL[$qual][$pos];
print OUTFILE $allTot, "\t";
}
} elsif($nuc == 1){
unless($DATA_A[$qual][$pos] == 0){
$aTot += $DATA_A[$qual][$pos];
print OUTFILE $aTot, "\t";
}
} elsif($nuc == 2){
unless($DATA_T[$qual][$pos] == 0){
$tTot += $DATA_T[$qual][$pos];
print OUTFILE $tTot, "\t";
}
} elsif($nuc == 3){
unless($DATA_G[$qual][$pos] == 0){
$gTot += $DATA_G[$qual][$pos];
print OUTFILE $gTot, "\t";
}
} elsif($nuc == 4){
unless($DATA_C[$qual][$pos] == 0){
$cTot += $DATA_C[$qual][$pos];
print OUTFILE $cTot, "\t";
}
} elsif($nuc == 5){
unless($DATA_N[$qual][$pos] == 0){
$nTot += $DATA_N[$qual][$pos];
print OUTFILE $nTot, "\t";
}
}
}
print OUTFILE "\n";
# re-set all totals to 0
$allTot = 0;
$aTot = 0;
$tTot = 0;
$gTot = 0;
$cTot = 0;
$nTot = 0;
}
}
# close the output file
close(OUTFILE);
# end summation.pl
exit;
|