This file is indexed.

/usr/bin/tqs is in ssake 3.8.4-1.

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
#!/usr/bin/env python

__doc__ = """
TQS

Trim Quality Solexa Sequences (TQS)

SYNOPSIS
   Quality trim solexa-Illumina sequence reads using user-defined thresholds 
"""
__author__ = "Rene L. Warren"
__version__ = '1.0'

#LICENSE
#   Copyright (c) 2007 Canada's Michael Smith Genome Science Centre.  All rights reserved.

#   This program is free software; you can redistribute it and/or
#   modify it under the terms of the GNU General Public License
#   as published by the Free Software Foundation; either version 2
#   of the License, or (at your option) any later version.

#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.

import sys, os, re, string
from datetime import datetime
from optparse import OptionParser


def main():
	usage = "Usage: %s --help"

	parser = OptionParser()
	parser.add_option("-f", "--sequence file", dest="seqfile",
	                  help="Illumina sequence file - Output format from the 1G Genome Analyzer (_seq.txt):                                       7       1       255     669     AACCCCCACTCCTACAACGCCATCATTCCCCTCGAC",)
	parser.add_option("-q", "--qual file", dest="qualfile",
	                  help="A prb file containing all the Illumina intensities, as outputted by the 1G Genome Analyzer (_prb.txt)",)
	parser.add_option("-l", "--length", dest="mer", type="int", default=36,
	                  help="Length of sequence reads (i.e. Number of sequencing cycles, default=36)",)
        parser.add_option("-t", "--threshold", dest="threshold", type="int", default=5,
                          help="Base intensity threshold value (-40 to 40, default=5)",)
        parser.add_option("-d", "--difference", dest="diff", type="int", default=5,
                          help="Base intensity difference between top intensity and second best (1 to 80, default=5)",)
        parser.add_option("-c", "--consec", dest="consec", type="int", default=20,
                          help="Minimum number of consecutive bases passing threshold values (default=20)",)
	parser.add_option("-v", "--verbose", dest="verbose", action="store_true",
	                  help="Runs in Verbose mode.",)
	(opts, args) = parser.parse_args()
	
	try:
		f = open(opts.seqfile)
		seq = f.readlines()
		f.close()
	except Exception, e:
		print "ERROR: Could not read from %s: %s" % (opts.seqfile, e)
		print usage % (sys.argv[0:])
		sys.exit()

        try:
                f = open(opts.qualfile)
                qual = f.readlines()
                f.close()
        except Exception, e:
                print "ERROR: Could not read from %s: %s" % (opts.qualfile, e)
                print usage % (sys.argv[0:])
                sys.exit()
	

	fasta = "%s_I%sD%sL%s.trim.fa" % (opts.seqfile,opts.threshold,opts.diff,opts.consec)
	log = "%s.log" % opts.seqfile


        try:
                FASTA = open(fasta, 'w')
        except:
                print "ERROR: Can not write to %s" % fasta
                sys.exit()

	try:
		LOG = open(log, 'w')
	except:
		print "ERROR: Can not write to %s" % log
		sys.exit()
	

	if opts.mer < 15 or opts.mer > 200:
		print "ERROR: -l must be a number between 15 and 200."
		sys.exit()
	
	if opts.consec < 16 or opts.consec > opts.mer:
		print "ERROR: -c must be a number between 16 and -l."
		sys.exit()

	LOG.write("""
Running:
%s
-f %s
-q %s
-l %s
-c %s
-t %s
-d %s
Fasta file: %s

""" % (sys.argv[0:],opts.seqfile, opts.qualfile, opts.mer, opts.consec, opts.threshold, opts.diff, fasta))
	
	t0 = datetime.now()
	LOG.write("\nReading Quality File: %s\n" % str(t0)[:len('2006-10-05 23:04')])
	trim_info = parseQualFile(opts.threshold, opts.diff, opts.consec, opts.mer, qual, opts.verbose, LOG)
        t1 = datetime.now()
        LOG.write("\n\nTrimming low quality bases: %s\n" % str(t1)[:len('2006-10-05 23:04')])
	readNTrim(trim_info, seq, opts.verbose, FASTA, LOG)
        LOG.write("DNA sequences have been trimmed accordingly and placed in %s" % fasta)
	
	LOG.close()
	FASTA.close()
	return	

#--------------------------------------------------------------------------------------
def parseQualFile(threshold, difference, consecutive, read_length, qual, verbose, LOG):
	"""
	Parse a solexa-illumina intensity file
	
	Return a Dictionary of sequence order number, with the index value and length to extract 
	"""
	trim_info = {}
	ok_read = 0
	read_number = 0

	if verbose:
		print "Printing trimming pattern for all reads passing the set threshold values...\n"
	
	for line in qual:
		read_number += 1                ### this keeps track of the read order, respected between the prb and seq files
		concat = ""			### concat builds a string of bases passing the user-defined filter 
		quartets = line.split("\t")	### split quartet (4 number per position)
		for quartet in quartets:	### cycle through each quartet
			quad = (quartet.split())
			quadint = []
                        for basequal in quad:	### each intensity/number for each position
				quadint.append(int(basequal))
                        quadint.sort()
			quadint.reverse()
			basediff = quadint[0] - quadint[1]
                        #print "T=%i D=%i" % (quadint[0],basediff)

			if quadint[0] < threshold or basediff < difference:
				concat += "x"
			else:
				concat += "-"

  		head_match_regex = re.compile("\-{%i,%i}" % (consecutive,read_length)) 
		head_match = head_match_regex.search(concat)
 		if head_match != None:
			ok_read += 1
			col = head_match.span()
                        if not trim_info.has_key(read_number):
                                trim_info[read_number] = {}

			start = int(col[0])	
			end = int(col[1])
	
			trim_info[read_number]['start'] = start
			trim_info[read_number]['end'] = end

			if verbose:
				sub = concat[trim_info[read_number]['start']:trim_info[read_number]['end']]
				print "passed seqs:%i line#%i %s (start trim:%i,length:%i) %s\n" % (ok_read, read_number, concat, start, end, sub)

	LOG.write("%i out of %i sequences passed your filter (I >= %i and D >= %i and L >= %i)\n" % (ok_read, read_number, threshold, difference, consecutive))

	return trim_info


#--------------------------------------------------------------------------------------
def readNTrim(trim_info, seq, verbose, FASTA, LOG):

	"""         
        Parse a solexa/illumina sequence file and trim DNA sequence based user-defined intensity threshold/differences
	"""	
       

	read_number = 0
	gDNAlinker_count = 0
	usable_reads = 0

        dna_sequence_field = re.compile('^[ACTG]+$')
	gDNAlinker1_field = re.compile('^ATCCCC[GA]A')
	gDNAlinker2_field = re.compile('^ATCTAACAG')	

	if verbose:
		print "Printing trimmed sequences for all reads passing the set threshold values minus, excluding sequence containing linkers...\n"

        for line in seq:
		read_number += 1            ### tracks read number / will match order in prb file
        	line = line.rstrip('\r\n')
		info = line.split("\t")     ### split line, the seq file lists: lane tile xcoord y coord DNAseq 
		dna_string = info[4]
	
		if trim_info.has_key(read_number):
			trim_seq = dna_string[trim_info[read_number]['start']:trim_info[read_number]['end']]
			if re.match(dna_sequence_field, trim_seq):		### no ambiguous bases?
				if re.match(gDNAlinker1_field, trim_seq) or re.match(gDNAlinker2_field,trim_seq):	### matches gDNA linker?
					gDNAlinker_count += 1
				else:
					usable_reads += 1
					FASTA.write(">%s-%s-%s-%s\n%s\n" % (info[0],info[1],info[2],info[3],trim_seq))
					if verbose:
						print "line#%i %s (start trim:%i,length:%i) %s" % (read_number,info[4],trim_info[read_number]['start'],trim_info[read_number]['end'],trim_seq)
	LOG.write("%i out of %i sequences appear to be usable, after filtering out sequences hard-coded in this program * %i gDNA linker sequences*\n" % (usable_reads, read_number,gDNAlinker_count))
	return

if __name__ == '__main__':
	main()
	import time
	sys.exit()