Mercurial > repos > charles_s_test > seqsero2
diff run_seqsero.py @ 9:acc5cd06a36a draft
planemo upload commit a4fb57231f274270afbfebd47f67df05babffa4a-dirty
author | charles_s_test |
---|---|
date | Tue, 28 Nov 2017 21:16:36 -0500 |
parents | 3d6680af0bec |
children | 53efef402c51 |
line wrap: on
line diff
--- a/run_seqsero.py Tue Nov 28 18:55:00 2017 -0500 +++ b/run_seqsero.py Tue Nov 28 21:16:36 2017 -0500 @@ -107,43 +107,44 @@ def get_serotypes(outputs): ''' ''' - fastq2comment = {} + fastq2comment = {} fastq2serotype = {} + for sample in outputs: - fastqs = '' - lines_used = [] + fastqs = '' + lines_used = [] for line in sample: # line is actually the entire seqsero output. line = str(line) linel = re.split("\n", line) # print(linel) #lines_used = [] for element in linel: # element is a line of seqsero output. - element = element.rstrip("\n") - test_out.write(element+"\n") + element = element.rstrip("\n") + test_out.write(element+"\n") elementl = re.split("\t", element) if elementl[0] == 'Input files:': fastqs = elementl[1] - lines_used.append(element) + lines_used.append(element) if elementl[1] not in fastq2serotype.keys(): fastq2serotype[fastqs] = ['']*5 - fastq2comment[fastqs] = [] + fastq2comment[fastqs] = [] elif elementl[0] == 'O antigen prediction:': - lines_used.append(element) + lines_used.append(element) fastq2serotype[fastqs][0] = elementl[1] # add predicted profile elif elementl[0] == 'H1 antigen prediction(fliC):': - lines_used.append(element) + lines_used.append(element) fastq2serotype[fastqs][1] = elementl[1] # add predicted profile elif elementl[0] == 'H2 antigen prediction(fljB):': - lines_used.append(element) + lines_used.append(element) fastq2serotype[fastqs][2] = elementl[1] # add predicted profile elif elementl[0] == 'Predicted antigenic profile:': - lines_used.append(element) + lines_used.append(element) fastq2serotype[fastqs][3] = elementl[1] # add predicted profile elif elementl[0] == 'Predicted serotype(s):': - lines_used.append(element) + lines_used.append(element) fastq2serotype[fastqs][4] = elementl[1] # add predicted serotype - if element not in lines_used and re.search("\w", fastqs) and len(element) > 7: - fastq2comment[fastqs].append(element) + if element not in lines_used and re.search("\w", fastqs) and len(element) > 7: + fastq2comment[fastqs].append(element) #print("\n" return fastq2serotype, fastq2comment @@ -151,7 +152,7 @@ ''' Takes dict and prints to html file. ''' - tab_out = open('Seqsero_result.txt', 'w'); + tab_out = open('Seqsero_result.txt', 'w'); html_out = open('Seqsero_result.html', 'w') html_out.write('<!DOCTYPE html>\n') html_out.write('<html>\n') @@ -182,19 +183,19 @@ html_out.write('</tr>\n') print(line_to_print) html_out.write('</table>\n') - print("\n") + print("\n") for fastq in fastq2comment: tab_out.write("\n"+fastq+"\n") html_out.write('<tr>\n') - html_out.write('<p>\n') + html_out.write('<p>\n') html_out.write('<td>'+fastq+"<br></td>\n") for line in fastq2comment[fastq]: #if len(line) > 7: html_out.write('<td>'+line+'</td>\n') tab_out.write(line+"\n") - print(line) - print("\n") - html_out.write('</p>\n') + print(line) + print("\n") + html_out.write('</p>\n') html_out.write('</tr>\n') html_out.write('</body>\n') html_out.write('</html>\n')