annotate calc_fitness.py @ 8:e783db184163 draft

Uploaded
author kaymccoy
date Fri, 12 Aug 2016 16:45:37 -0400
parents 61bd336c50c2
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
1 # A translation of calc_fitness.pl into python! For analysis of Tn-Seq.
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
2 # This script requires BioPython, which in turn has a good number of dependencies (some optional but very helpful).
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
3 # How to install BioPython and a list of its dependencies can be found here: http://biopython.org/DIST/docs/install/Installation.html
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
4 # K. McCoy
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
5
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
6
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
7
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
8
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
9
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
10
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
11
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
12
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
13
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
14 ##### ARGUMENTS #####
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
15
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
16 def print_usage():
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
17 print "\n" + "You are missing one or more required flags. A complete list of flags accepted by calc_fitness is as follows:" + "\n\n"
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
18 print "\033[1m" + "Required" + "\033[0m" + "\n"
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
19 print "-ref" + "\t\t" + "The name of the reference genome file, in GenBank format." + "\n"
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
20 print "-t1" + "\t\t" + "The name of the bowtie mapfile from time 1." + "\n"
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
21 print "-t2" + "\t\t" + "The name of the bowtie mapfile from time 2." + "\n"
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
22 print "-out" + "\t\t" + "Name of a file to enter the .csv output." + "\n"
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
23 print "\n"
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
24 print "\033[1m" + "Optional" + "\033[0m" + "\n"
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
25 print "-expansion" + "\t\t" + "Expansion factor (default: 250)" + "\n"
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
26 print "-d" + "\t\t" + "All reads being analyzed are downstream of the transposon" + "\n"
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
27 print "-reads1" + "\t\t" + "The number of reads to be used to calculate the correction factor for time 0." + "\n\t\t" + "(default counted from bowtie output)" + "\n"
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
28 print "-reads2" + "\t\t" + "The number of reads to be used to calculate the correction factor for time 6." + "\n\t\t" + "(default counted from bowtie output)" + "\n"
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
29 print "-cutoff" + "\t\t" + "Discard any positions where the average of counted transcripts at time 0 and time 1 is below this number (default 0)" + "\n"
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
30 print "-cutoff2" + "\t\t" + "Discard any positions within the normalization genes where the average of counted transcripts at time 0 and time 1 is below this number (default 0)" + "\n"
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
31 print "-strand" + "\t\t" + "Use only the specified strand (+ or -) when counting transcripts (default: both)" + "\n"
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
32 print "-normalize" + "\t" + "A file that contains a list of genes that should have a fitness of 1" + "\n"
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
33 print "-maxweight" + "\t" + "The maximum weight a transposon gene can have in normalization calculations" + "\n"
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
34 print "-multiply" + "\t" + "Multiply all fitness scores by a certain value (e.g., the fitness of a knockout). You should normalize the data." + "\n"
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
35 print "-ef" + "\t\t" + "Exclude insertions that occur in the first N amount (%) of gene--becuase may not affect gene function." + "\n"
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
36 print "-el" + "\t\t" + "Exclude insertions in the last N amount (%) of the gene--considering truncation may not affect gene function." + "\n"
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
37 print "-wig" + "\t\t" + "Create a wiggle file for viewing in a genome browser. Provide a filename." + "\n"
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
38 print "-uncol" + "\t\t" + "Use if reads were uncollapsed when mapped." + "\n"
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
39 print "\n"
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
40
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
41 import argparse
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
42 parser = argparse.ArgumentParser()
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
43 parser.add_argument("-ref", action="store", dest="ref_genome")
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
44 parser.add_argument("-t1", action="store", dest="mapfile1")
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
45 parser.add_argument("-t2", action="store", dest="mapfile2")
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
46 parser.add_argument("-out", action="store", dest="outfile")
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
47 parser.add_argument("-out2", action="store", dest="outfile2")
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
48 parser.add_argument("-expansion", action="store", dest="expansion_factor")
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
49 parser.add_argument("-d", action="store", dest="downstream")
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
50 parser.add_argument("-reads1", action="store", dest="reads1")
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
51 parser.add_argument("-reads2", action="store", dest="reads2")
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
52 parser.add_argument("-cutoff", action="store", dest="cutoff")
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
53 parser.add_argument("-cutoff2", action="store", dest="cutoff2")
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
54 parser.add_argument("-strand", action="store", dest="usestrand")
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
55 parser.add_argument("-normalize", action="store", dest="normalize")
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
56 parser.add_argument("-maxweight", action="store", dest="max_weight")
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
57 parser.add_argument("-multiply", action="store", dest="multiply")
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
58 parser.add_argument("-ef", action="store", dest="exclude_first")
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
59 parser.add_argument("-el", action="store", dest="exclude_last")
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
60 parser.add_argument("-wig", action="store", dest="wig")
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
61 parser.add_argument("-uncol", action="store", dest="uncol")
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
62 arguments = parser.parse_args()
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
63
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
64 if (not arguments.ref_genome or not arguments.mapfile1 or not arguments.mapfile2 or not arguments.outfile):
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
65 print_usage()
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
66 quit()
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
67
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
68 # Sets the default value of the expansion factor to 250, which is a trivial placeholder number.
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
69
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
70 if (not arguments.expansion_factor):
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
71 arguments.expansion_factor = 250
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
72
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
73 # 75 is similarly trivial
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
74
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
75 if (not arguments.max_weight):
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
76 arguments.max_weight = 75
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
77
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
78 # Sets the default value of cutoff to 0; cutoff exists to discard positions with a low number of counted transcripts, because fitnesses calculated from them may not be very accurate, by the same reasoning that studies with low sample sizes are innacurate.
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
79
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
80 if (not arguments.cutoff):
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
81 arguments.cutoff = 0
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
82
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
83 # Sets the default value of cutoff2 to 10; cutoff2 exists to discard positions within normalization genes with a low number of counted transcripts, because fitnesses calculated from them similarly may not be very accurate.
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
84 # This only has an effect if it's larger than cutoff, since the normalization step references a list of insertions already affected by cutoff.
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
85
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
86 if (not arguments.cutoff2):
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
87 arguments.cutoff2 = 10
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
88
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
89 if (not arguments.usestrand):
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
90 arguments.usestrand = "both"
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
91
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
92
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
93
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
94
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
95
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
96
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
97 ##### PARSING THE REFERENCE GENOME #####
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
98
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
99 def get_time():
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
100 import datetime
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
101 return datetime.datetime.now().time()
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
102 print "\n" + "Starting: " + str(get_time()) + "\n"
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
103
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
104 from Bio import SeqIO
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
105 import os.path
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
106 handle = open(arguments.ref_genome, "rU")
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
107 for record in SeqIO.parse(handle, "genbank"):
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
108 refname = record.id
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
109 features = record.features
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
110 handle.close()
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
111
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
112 # Makes a dictionary out of each feature that's a gene - with its gene name, start location, end location, and strand as keys to their values. Then makes a list out of all those dictionaries for ease of accessing later on.
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
113
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
114 feature_list = []
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
115 for feature in features:
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
116 if feature.type == "gene":
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
117 gene = feature.qualifiers["locus_tag"]
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
118 strand = feature.location.strand
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
119 start = float(feature.location.start)
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
120 end = float(feature.location.end)
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
121
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
122 # Exclude_first and exclude_last are used here to exclude whatever percentage of the genes you like from calculations; e.g. a value of 0.1 for exclude_last would exclude the last 10% of all genes!
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
123 # This can be useful because insertions at the very start or end of genes often don't actually break its function.
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
124
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
125 if (arguments.exclude_first):
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
126 start += (end - start) * float(arguments.exclude_first)
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
127 if (arguments.exclude_last):
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
128 end -= (end - start) * float(arguments.exclude_last)
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
129 feature_dictionary = {"gene": gene, "start": start, "end": end, "strand": strand}
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
130 feature_list.append(feature_dictionary)
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
131
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
132 print "Done generating feature lookup: " + str(get_time()) + "\n"
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
133
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
134
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
135
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
136
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
137
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
138
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
139
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
140
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
141
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
142
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
143 ##### PARSING THE MAPFILES #####
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
144
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
145 with open(arguments.mapfile1) as file:
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
146 r1 = file.readlines()
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
147 with open(arguments.mapfile2) as file:
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
148 r2 = file.readlines()
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
149
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
150 # When called, goes through each line of the mapfile to find the strand (+/Watson or -/Crick), count, and position of the read. It may be helpful to look at how the mapfiles are formatted to understand how this code finds them.
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
151
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
152 def read_mapfile(reads):
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
153 plus_total = 0
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
154 minus_total = 0
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
155 plus_counts = {"total": 0, "sites": 0}
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
156 minus_counts = {"total": 0, "sites": 0}
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
157 for read in reads:
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
158 if (arguments.uncol):
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
159 strand = read.split()[2]
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
160 count = 1
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
161 position = float(read.split()[4])
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
162 if arguments.usestrand != "both" and strand != arguments.usestrand:
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
163 continue
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
164 if (strand == "+"):
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
165 sequence_length = len(read.split()[5])
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
166 if arguments.downstream:
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
167 position += 0
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
168 else:
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
169 position += (sequence_length - 2)
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
170 plus_counts["total"] += count
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
171 plus_counts["sites"] += 1
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
172 if position in plus_counts:
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
173 plus_counts[position] += count
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
174 else:
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
175 plus_counts[position] = count
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
176 else:
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
177 minus_counts["total"] += count
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
178 minus_counts["sites"] += 1
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
179 if position in minus_counts:
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
180 minus_counts[position] += count
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
181 else:
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
182 minus_counts[position] = count
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
183 else:
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
184 if "-" in read.split()[0]:
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
185 strand = read.split()[1]
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
186 count = float(read.split()[0].split("-")[1])
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
187 position = float(read.split()[3])
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
188 else:
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
189 continue
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
190
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
191 # If for some reason you want to skip all reads from one of the strands - for example, if you wanted to compare the two strands - that's done here.
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
192
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
193 if arguments.usestrand != "both" and strand != arguments.usestrand:
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
194 continue
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
195
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
196 # Makes dictionaries for the + & - strands, with each insert position as a key and the number of insertions there as its corresponding value.
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
197
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
198 if (strand == "+"):
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
199 sequence_length = len(read.split()[4])
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
200 if arguments.downstream:
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
201 position += 0
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
202
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
203 # The -2 in "(sequence_length -2)" comes from a fake "TA" in the read; see how the libraries are constructed for further on this
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
204
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
205 else:
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
206 position += (sequence_length - 2)
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
207 plus_counts["total"] += count
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
208 plus_counts["sites"] += 1
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
209 if position in plus_counts:
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
210 plus_counts[position] += count
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
211 else:
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
212 plus_counts[position] = count
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
213 else:
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
214 minus_counts["total"] += count
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
215 minus_counts["sites"] += 1
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
216 if position in minus_counts:
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
217 minus_counts[position] += count
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
218 else:
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
219 minus_counts[position] = count
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
220 return (plus_counts, minus_counts)
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
221
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
222 # Calls read_mapfile(reads) to parse arguments.reads1 and arguments.reads2 (your reads from t1 and t2).
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
223
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
224
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
225
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
226
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
227
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
228 (plus_ref_1, minus_ref_1) = read_mapfile(r1)
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
229 print "Read first file: " + str(get_time()) + "\n"
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
230 (plus_ref_2, minus_ref_2) = read_mapfile(r2)
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
231 print "Read second file: " + str(get_time()) + "\n"
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
232
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
233 # The lines below are just printed for reference. The number of sites is the length of a given dictionary of sites - 1 because its last key, "total", isn't actually a site.
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
234
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
235 print "Reads:" + "\n"
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
236 print "1: + " + str(plus_ref_1["total"]) + " - " + str(minus_ref_1["total"]) + "\n"
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
237 print "2: + " + str(plus_ref_2["total"]) + " - " + str(minus_ref_2["total"]) + "\n"
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
238 print "Sites:" + "\n"
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
239 print "1: + " + str(plus_ref_1["sites"]) + " - " + str(minus_ref_1["sites"]) + "\n"
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
240 print "2: + " + str(plus_ref_2["sites"]) + " - " + str(minus_ref_2["sites"]) + "\n"
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
241
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
242
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
243
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
244
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
245
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
246
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
247
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
248
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
249
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
250
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
251 ##### FITNESS CALCULATIONS #####
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
252
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
253 # If reads1 and reads2 weren't specified in the command line, sets them as the total number of reads (found in read_mapfile())
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
254
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
255 if not arguments.reads1:
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
256 arguments.reads1 = plus_ref_1["total"] + minus_ref_1["total"]
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
257 if not arguments.reads2:
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
258 arguments.reads2 = plus_ref_2["total"] + minus_ref_2["total"]
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
259
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
260 # Calculates the correction factors for reads from t1 and t2; cfactor1 and cfactor2 are the number of reads from t1 and t2 respectively divided by total, which is the average number of reads between the two.
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
261 # This is used later on to correct for pipetting errors, or any other error that would cause unequal amounts of DNA from t1 and t2 to be sequenced so that an unequal amount of reads is produced
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
262
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
263 total = (float(arguments.reads1) + float(arguments.reads2))/2
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
264 cfactor1 = float(arguments.reads1)/total
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
265 cfactor2 = float(arguments.reads2)/total
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
266 print "Cfactor 1: " + str(cfactor1) + "\n"
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
267 print "Cfactor 2: " + str(cfactor2) + "\n"
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
268 import math
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
269 import csv
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
270 results = [["position", "strand", "count_1", "count_2", "ratio", "mt_freq_t1", "mt_freq_t2", "pop_freq_t1", "pop_freq_t2", "gene", "D", "W", "nW"]]
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
271 genic = 0
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
272 total_inserts = 0
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
273 with open(arguments.ref_genome, "r") as file:
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
274 firstline = file.readline()
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
275 genomelength = firstline.split()[2]
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
276 i = 0
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
277 while i < float(genomelength):
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
278
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
279 # At each possible location for an insertion in the genome, counts the number of actual insertions at t1 and which strand(s) the corresponding reads came from.
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
280
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
281 c1 = 0
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
282 if i in plus_ref_1:
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
283 c1 = float(plus_ref_1[i])
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
284 strand = "+/"
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
285 if i in minus_ref_1:
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
286 c1 += float(minus_ref_1[i])
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
287 strand = "b/"
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
288 elif i in minus_ref_1:
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
289 c1 = float(minus_ref_1[i])
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
290 strand = "-/"
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
291
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
292 # If there were no insertions at a certain location at t1 just continues to the next location; there can't be any comparison to make between t1 and t2 if there are no t1 insertions!
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
293
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
294 else:
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
295 i += 1
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
296 continue
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
297
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
298 # At each location where there was an insertion at t1, counts the number of insertions at t2 and which strand(s) the corresponding reads came from.
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
299
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
300 c2 = 0
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
301 if i in plus_ref_2:
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
302 c2 = float(plus_ref_2[i])
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
303 if i in minus_ref_2:
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
304 c2 += float(minus_ref_2[i])
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
305 strand += "b"
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
306 else:
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
307 strand += "+"
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
308 elif i in minus_ref_2:
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
309 c2 = float(minus_ref_2[i])
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
310 strand += "-"
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
311
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
312 # Corrects with cfactor1 and cfactor2
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
313
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
314 c1 /= cfactor1
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
315 if c2 != 0:
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
316 c2 /= cfactor2
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
317 ratio = c2/c1
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
318 else:
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
319 c2 = 0
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
320 ratio = 0
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
321
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
322 # Passes by all insertions with a number of reads smaller than the cutoff, as they may lead to inaccurate fitness calculations.
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
323
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
324 if (c1 + c2)/2 < float(arguments.cutoff):
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
325 i+= 1
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
326 continue
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
327
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
328 # Calculates each insertion's frequency within the populations at t1 and t2.
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
329
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
330 mt_freq_t1 = c1/total
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
331 mt_freq_t2 = c2/total
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
332 pop_freq_t1 = 1 - mt_freq_t1
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
333 pop_freq_t2 = 1 - mt_freq_t2
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
334
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
335 # Calculates each insertion's fitness! This is from the fitness equation log((frequency of mutation @ time 2 / frequency of mutation @ time 1)*expansion factor)/log((frequency of population without the mutation @ time 2 / frequency of population without the mutation @ time 1)*expansion factor)
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
336
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
337 w = 0
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
338 if mt_freq_t2 != 0:
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
339 top_w = math.log(mt_freq_t2*(float(arguments.expansion_factor)/mt_freq_t1))
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
340 bot_w = math.log(pop_freq_t2*(float(arguments.expansion_factor)/pop_freq_t1))
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
341 w = top_w/bot_w
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
342
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
343 # Checks which gene locus the insertion falls within, and records that.
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
344
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
345 gene = ''
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
346 for feature_dictionary in feature_list:
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
347 if feature_dictionary["start"] <= i and feature_dictionary["end"] >= i:
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
348 gene = "".join(feature_dictionary["gene"])
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
349 genic += 1
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
350 break
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
351 total_inserts += 1
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
352
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
353 # Writes all relevant information on each insertion and its fitness to a cvs file: the location of the insertion, its strand, c1, c2, etc. (the variable names are self-explanatiory)
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
354 # w is written twice, because the second w will be normalized if normalization is called for, thus becoming nW.
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
355
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
356 row = [i, strand, c1, c2, ratio, mt_freq_t1, mt_freq_t2, pop_freq_t1, pop_freq_t2, gene, arguments.expansion_factor, w, w]
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
357 results.append(row)
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
358 i += 1
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
359 with open(arguments.outfile, "wb") as csvfile:
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
360 writer = csv.writer(csvfile)
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
361 writer.writerows(results)
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
362
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
363 print "Done comparing mapfiles " + str(get_time()) + "\n"
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
364 print "Genic: " + str(genic) + "\n"
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
365 print "Total: " + str(total_inserts) + "\n"
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
366
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
367
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
368
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
369
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
370
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
371
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
372
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
373
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
374
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
375
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
376 ##### NORMALIZATION #####
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
377
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
378 # If making a WIG file is requested in the arguments, starts a string to be added to and then written to the WIG file with a typical WIG file header.
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
379 # The header is just in a typical WIG file format; if you'd like to look into this more UCSC has notes on formatting WIG files on their site.
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
380
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
381 if (arguments.wig):
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
382 wigstring = "track type=wiggle_0 name=" + arguments.wig + "\n" + "variableStep chrom=" + refname + "\n"
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
383
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
384 # Takes normalization genes (which should all be predicted or known to have fitness values of exactly 1.0, like transposons for example) and uses them to normalize the fitnesses of all insertion locations
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
385
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
386 if (arguments.normalize):
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
387 with open(arguments.normalize) as file:
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
388 transposon_genes = file.read().splitlines()
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
389 print "Normalize genes loaded" + "\n"
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
390 blank_ws = 0
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
391 sum = 0
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
392 count = 0
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
393 weights = []
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
394 scores = []
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
395 for list in results:
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
396 if list[9] != '' and list[9] in transposon_genes: # and list[11]:
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
397 c1 = list[2]
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
398 c2 = list[3]
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
399 score = list[11]
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
400 avg = (c1 + c2)/2
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
401
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
402 # Skips over those insertion locations with too few insertions - their fitness values are less accurate because they're based on such small insertion numbers.
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
403
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
404 if float(c1) >= float(arguments.cutoff2):
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
405
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
406 # Sets a max weight, to prevent insertion location scores with huge weights from unbalancing the normalization.
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
407
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
408 if (avg >= float(arguments.max_weight)):
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
409 avg = float(arguments.max_weight)
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
410
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
411 # Tallies how many w values are 0 within the blank_ws value; you might get many transposon genes with a w value of 0 if a bottleneck occurs, for example, which is especially common with in vivo experiments. This is used later by aggregate.py
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
412 # For example, when studying a nasal infection in a mouse model, what bacteria "sticks" and is able to survive and what bacteria is swallowed and killed or otherwise flushed out tends to be a matter of chance not fitness; all mutants with an insertion in a specific transposon gene could be flushed out by chance!
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
413
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
414 if score == 0:
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
415 blank_ws += 1
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
416
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
417 sum += score
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
418 count += 1
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
419 weights.append(avg)
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
420 scores.append(score)
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
421
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
422 print str(list[9]) + " " + str(score) + " " + str(c1)
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
423
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
424 # Counts and removes all "blank" fitness values of normalization genes - those that = 0 - because they most likely don't really have a fitness value of 0, and you just happened to not get any reads from that location at t2.
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
425
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
426 blank_count = 0
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
427 original_count = len(scores)
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
428 curr_count = original_count
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
429 i = 0
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
430 while i < curr_count:
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
431 w_value = scores[i]
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
432 if w_value == 0:
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
433 blank_count += 1
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
434 weights.pop(i)
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
435 scores.pop(i)
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
436 i -= 1
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
437 curr_count = len(scores)
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
438 i += 1
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
439
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
440 # If no normalization genes can pass the cutoff, normalization cannot occur, so this ends the script advises the user to try again and lower cutoff and/or cutoff2.
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
441
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
442 if len(scores) == 0:
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
443 print 'ERROR: The normalization genes do not have enough reads to pass cutoff and/or cutoff2; please lower one or both of those arguments.' + "\n"
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
444 quit()
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
445
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
446 pc_blank_normals = float(blank_count) / float(original_count)
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
447 print "# blank out of " + str(original_count) + ": " + str(pc_blank_normals) + "\n"
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
448 with open(arguments.outfile2, "w") as f:
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
449 f.write("blanks: " + str(pc_blank_normals) + "\n" + "total: " + str(total) + "\n" + "refname: " + refname)
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
450
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
451 average = sum / count
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
452 i = 0
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
453 weighted_sum = 0
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
454 weight_sum = 0
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
455 while i < len(weights):
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
456 weighted_sum += weights[i]*scores[i]
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
457 weight_sum += weights[i]
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
458 i += 1
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
459 weighted_average = weighted_sum/weight_sum
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
460
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
461 print "Normalization step:" + "\n"
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
462 print "Regular average: " + str(average) + "\n"
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
463 print "Weighted Average: " + str(weighted_average) + "\n"
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
464 print "Total Insertions: " + str(count) + "\n"
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
465
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
466 old_ws = 0
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
467 new_ws = 0
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
468 wcount = 0
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
469
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
470 for list in results:
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
471 if list[11] == 'W':
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
472 continue
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
473 new_w = float(list[11])/weighted_average
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
474
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
475 # Sometimes you want to multiply all the fitness values by a constant; this does that.
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
476 # For example you might multiply all the values by a constant for a genetic interaction screen - where Tn-Seq is performed as usual except there's one background knockout all the mutants share.
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
477
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
478 if arguments.multiply:
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
479 new_w *= float(arguments.multiply)
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
480
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
481 if float(list[11]) > 0:
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
482 old_ws += float(list[11])
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
483 new_ws += new_w
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
484 wcount += 1
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
485
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
486 list[12] = new_w
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
487
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
488 if (arguments.wig):
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
489 wigstring += str(list[0]) + " " + str(new_w) + "\n"
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
490
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
491 old_w_mean = old_ws / wcount
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
492 new_w_mean = new_ws / wcount
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
493 print "Old W Average: " + str(old_w_mean) + "\n"
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
494 print "New W Average: " + str(new_w_mean) + "\n"
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
495
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
496 with open(arguments.outfile, "wb") as csvfile:
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
497 writer = csv.writer(csvfile)
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
498 writer.writerows(results)
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
499
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
500 if (arguments.wig):
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
501 if (arguments.normalize):
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
502 with open(arguments.wig, "wb") as wigfile:
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
503 wigfile.write(wigstring)
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
504 else:
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
505 for list in results:
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
506 wigstring += str(list[0]) + " " + str(list[11]) + "\n"
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
507 with open(arguments.wig, "wb") as wigfile:
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
508 wigfile.write(wigstring)
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
509
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
510
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
511
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
512
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
513
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
514
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
515
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
516
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
517
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
518
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
519
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
520
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
521
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
522
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
523
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
524
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
525
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
526
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
527
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
528
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
529
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
530
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
531
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
532
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
533
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
534
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
535
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
536
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
537
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
538
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
539
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
540
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
541
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
542
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
543
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
544
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
545
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
546
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
547
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
548
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
549
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
550
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
551
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
552
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
553
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
554
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
555
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
556
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
557
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
558
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
559
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
560
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
561
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
562
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
563
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
564
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
565
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
566
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
567
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
568
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
569
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
570
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
571
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
572
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
573
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
574
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
575
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
576
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
577
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
578
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
579
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
580
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
581
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
582
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
583
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
584
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
585
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
586
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
587
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
588
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
589
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
590
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
591
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
592
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
593
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
594
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
595
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
596
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
597
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
598
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
599
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
600
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
601
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
602
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
603
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
604
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
605
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
606
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
607
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
608
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
609
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
610 # `````````````
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
611 # `````````````
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
612 # ``@@@@@@@@@``
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
613 # ``@@@@@@@@@```
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
614 # ``@@@@@@@@@``
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
615 # ``@@@@@@@@@``
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
616 # ``@@@@@@@@@``
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
617 # ``@@@@@@@@@``
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
618 # ```@@@@@@@@#``
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
619 # ```@@@@@@@@#``
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
620 # ```@@@@@@@@+``
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
621 # ```@@@@@@@@'``
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
622 # ```@@@@@@@@;``
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
623 # ```@@@@@@@@;``
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
624 # ```@@@@@@@@:``
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
625 # ```@@@@@@@@,``
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
626 # ``.@@@@@@@@.``
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
627 # ``.@@@@@@@@```
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
628 # ``.@@@@@@@@```
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
629 # ``.@@@@@@@@```
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
630 # ``.@@@@@@@@``
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
631 # ``,@@@@@@@@``
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
632 # ``,@@@@@@@@``
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
633 # ``.@@@@@@@@``
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
634 # ```@@@@@@@@``
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
635 # ``:@@@@@@@@``
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
636 # ``:@@@@@@@@``
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
637 # ``:@@@@@@@@``
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
638 # ``:@@@@@@@@``
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
639 # ``'@@@@@@@@``
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
640 # ``;@@@@@@@@``
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
641 # ``:@@@@@@@@``
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
642 # ``:@@@@@@@@``
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
643 # ``:@@@@@@@@``
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
644 # ``;@@@@@@@#``
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
645 # ````+@@@@@@@#`````
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
646 # ```````#@@@@@@@#``````
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
647 # `````.,@@@@@@@@@...````
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
648 # ``@@@@@@@@@@@@@@@@@@;``
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
649 # ``@@@@@@@@@@@@@@@@@@;``
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
650 # ```````````````````````
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
651 # `````````````````````
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
652 # ``````.```````
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
653 # ````@.''```
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
654 # ```# `;```
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
655 # ``.+ @```
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
656 # ```@ ````,+```
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
657 # ```;;````` @```
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
658 # ```@ ``````,@```
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
659 # ```,+```..```@```
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
660 # ```@ ``....```@```
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
661 # ```+' ``....```#'``
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
662 # ```@```......`` @```
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
663 # ```'+```......```'@```
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
664 # ```@ ``........```@```
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
665 # ```'#```........````@```
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
666 # ```@ ``..........```#,``
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
667 # ```'#```...........`` @```
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
668 # ```@``.............```.+```
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
669 # ```:#```.............`` #```
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
670 # ``````` ```@ ```.......#......``.@```
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
671 # `````````` ```:@```#`......@......```@```
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
672 # ``````#@@@`` ```@ `.`:.......@.......`` @```
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
673 # ```.#@###@`` ```:@``..`+`....`@.......```@,``
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
674 # ```'@####@``` ```@````..@@@@@@@@#,`..#```` @```
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
675 # ```#####@@``` ``;@ ,`.,@@. `@@..#..```''``
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
676 # ``:####@#```` ```@``@`@@ @@:...`` @```
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
677 # ```@#####```` ``,@``.@, ,@`...``:@```
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
678 # ``.####@``` ```@.` @` @....``@```
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
679 # ``####@``` ``,@ @.` @`.````@```
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
680 # ``@##@```` ```@, @: ;# `@..```@.``
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
681 # ```@##```` ``.@`,@ @@, #...`` @```
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
682 # ```@#@``` ```@, # `@@@ @`.```;'``
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
683 # ```##:`` ``.@ +, .@@@ ,'..`` @```
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
684 # ``.##``` ```@, @ `@@@ @`.```,+```
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
685 # `````@##``` ```@`'. @@@ :...```@``` ``````````
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
686 # ````````````````````````````````````````##@``` ```@:`@ @@@ #...`` #``` `````````````````
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
687 # ```````````````````````````````````````.###@``` ```@ `, .@@@++'++#@@'` #`..```#``` ````````````'@@@@@.````
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
688 # `````+@####################@@@@@@@@@@@@#####@``` ```#;`,. `@#...,.,,,,,,..;@, @....`` @``````````````+@@@########@.``
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
689 # `+@##########################################,```` ```````````````@```@ +@,.,,,,,,,,,,,,,,,,,@ @....```#`````````'@@@##############@```
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
690 # `@###########################################@``````````````````````````````````````+'``.,'.#.,,,,,,,,,,,,,,,,,,,,.++@......`` @````+@@@#######@+``````'###'``
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
691 # ``:@@########@@@@@@@@@@@@@@@@@@@@@@#@@@@@@@##@``````````````````````````......,`,,.,@ ```.##.,.,,,,,,,,,,,,,,,,,,,,.##......`` :.+@@#######@@:``````````###@```
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
692 # ````````````````````````````````,#########@###@@@@#################################@'```...@.,,,,,,,,,,,,,,,,,,,,,,,#.........`'@######@@+```````````````@##```
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
693 # ```````````````````````````````@#########@#########################################```.....@:,,,,,,,,,,,,,,,,,,..;@..........`@####@@:```````` ```@##@``
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
694 # `````@@####@@@##########@@@@@@@@@@@@@@@@@@@@@@@@@@@@#+@+```......@#.,,,,,,,,,,,,,,,,.##..........`` #@#````````` ```##@```
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
695 # ``.#@######@####:```````````````````````````````````@ ``.......@:#,,,,,,,,,,,,,,,;@@`............`` @`````` ```@##:``
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
696 # ``:########@###@```````````````````````````````````#;```......+..`##,.,,,,,,,,.#@#..'............`` @```` ``;##@```
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
697 # ```@@####@@##@'```` ````@ ``.......'.....@@#+;:;'#@@;`...#`............`` @``` ```@##```
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
698 # ```````````````` ```@,```.............'..:''':.@`......:............```@.`` ``@###```
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
699 # `````````````` ``.@```..............#........'`....................```@``` ``.##@``````
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
700 # ```@.``..............`#........,.....................```@.`` ```@#+,``````
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
701 # ``.@``.,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,.................```@``` ````+#####@````
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
702 # ```@````......,........................,....,,.,.,,,,,..` @,`` ```;@@######````
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
703 # ``.@```.......,......................`......,...........```@``` ```+#########@````
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
704 # ```@```...........`@@+...............+@@`....,...........```@:`` ``;@#########@'```
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
705 # ``.@ ``............@@@@@`.........,@@@@@.....,............```@``` ``@#########@#@@```
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
706 # ```@.```............@@@@@@@`.....'@@@@@@@.....,............```#'`` ``@###@###@#@#@@@``
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
707 # ``.@```.............@@@@@@@@@..+#@@@@@@@@.....,.............`` #``` ``@#@@@@##@#@#@@@``
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
708 # ```@````.............@@@@@@@@@@@@@@@@@@@@@.....,.............```'#``` ``'#@@@@##@#@@@@@,`
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
709 # ``.@ ``.........,....@@@@@@@@@',##@@@@@@@@`....,..............```@``` ```@@@@@##@@'#@@@@`
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
710 # ```@.```.........,....@@@@@@@#`...`#@@@@@@@`....,..............```.@``` ``#@@@@##;```@@@@`
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
711 # ``.@ ``.....,,,,,,,.,.@@@@@#.,,,,,,,.#@@@@@,,,,,,,,,,,,:,,,,,,,,.``@``` ``#@@@@#.````@@@@`
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
712 # ```@. ``...............@@@;......,......#@@@`...........,.........```@``` ``#@@@;``````@@@@`
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
713 # ```@```................@,........,........+#`...........,.........```@.`` ``#@@@;``````@@@@`
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
714 # ```@.``...........................,.........`............,..........```@``` ``#@@@'`` ``#@@;`
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
715 # ``.@ ``................,..........,......................,..........```#:`` ``#@@@'`` ```#@``
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
716 # ```@,``............................,......................,...........`` @``` ``+@@@'`` `````
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
717 # ``.@```............................,......................,...........```#+`` ``;@@@+`` ``
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
718 # ```@,``.............................,......................,............```@``` ``'@@@+``
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
719 # ``.@```.........,...................,......................,............```'#``` ``;@@@+``
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
720 # ```@:```.........,...................,......................,.............`` @``` ``:@@@+``
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
721 # ```@`..,,,,,,,,,,,,,,,,,,..,.........,......................,.............```'@``` ``;@@@#``
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
722 # ``+'```...,.................,....,,,,,,,,,,,,,,,,,,,,,,,,,,,,,..........,...``@``` ``;@@@#``
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
723 # ```@ ``....,.................,.......................................,.......``;@``` ``:@@@#``
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
724 # ``'#```....,.................,.......................................,.......```@``` ``:@@@@``
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
725 # ```@```.....,.................,.......................................,........``;#`` ``:@@@@``
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
726 # ```@ ``.....,.................,.......................................,........`` @``` ``:@@@@``
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
727 # ``@````...............................................................,........`` @.`` ``;@@@@``
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
728 # ``@ ```..............................................................,........`` .#`` ``'@@@@``
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
729 # ``# ``````.`.```````````````..````````````````````..`````````````````.`````````` @`` ``'@@@@``
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
730 # ``. `````````````````````````````````````````````````````````````````````````` .;`` ``'@@@@``
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
731 # ``@;` `` ` ` ` ` ```` ` ````` ` ` `,+@``` ``+@@@@``
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
732 # `````:;'++##@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@+.```` ``+@@@@``
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
733 # ```````````````````````````+##@``````````````````@#@``````````````````````````````` ``+@@@@``
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
734 # `````````````````````````@##@``````````````````@##;```````````````````````````` ``+@@@@``
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
735 # ````###,```` ````+##@``` ``+@@@@``
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
736 # ``,###``` ``.@##``` ``'@@@@``
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
737 # ``###@`` ```@##``` ``'@@@@``
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
738 # ```@##@`` ``@##+`` ``'@@@@``
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
739 # ```###.`` ``:##@`` ``'@@@@``
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
740 # ``:###``` ```##@``` ``'@@@@``
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
741 # ``@##@`` ```@##``` ``'@@@@``
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
742 # ```@##'`` ``@###`` ``'@@@@``
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
743 # ```@##``` ```##@`` ``'@@@@``
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
744 # ``,###``` ```@#@``` ``'@@@@``
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
745 # ``####`` ``@##.`` ``'@@@@``
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
746 # ``@##@`` ``;##@`` ``'@@@@``
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
747 # `````````@##@`` ```##@```` ``;@@@@``
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
748 # ``````````````@##;`` ```###`````````````` ``;@@@@``
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
749 # `````````.,;.```###``` ``@##:`````````````` ``;@@@@``
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
750 # `````#@#########@@##``` ``###@@@@@@###@#@'``` ``;@@@@``
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
751 # ```@@###############@`` ``,################`` ``;@@@@``
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
752 # ``'@################+`` ```###############+`` ``;@@@@``
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
753 # `````````````````````` ``###########@#,```` ``.@@@@``
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
754 # ````````````````````` ``````````````````` ```@@@.`
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
755 # ```````````````` ```````
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
756 #
61bd336c50c2 Uploaded
kaymccoy
parents:
diff changeset
757 #