# HG changeset patch # User Jim Johnson # Date 1389991853 21600 # Node ID 856033fb26e83c5ad65f457b09544f8048608f32 # Parent fe0327a3ba814a0e1440b3a97addb24c120dcb26 Add case insensitive option diff -r fe0327a3ba81 -r 856033fb26e8 find_in_reference.py --- a/find_in_reference.py Sat Jan 04 09:03:57 2014 -0500 +++ b/find_in_reference.py Fri Jan 17 14:50:53 2014 -0600 @@ -40,6 +40,7 @@ parser.add_option( '-f', '--filtered', dest='filtered', help='The output file for input lines not in the output') parser.add_option('-c','--input_column', dest='input_column', default=None, help='The column for the value in the input file. (first column = 1, default to last column)') parser.add_option('-C','--reference_column', dest='reference_column', default=None, help='The column for the value in the reference file. (first column = 1, default to last column)') + parser.add_option( '-I', '--case_insensitive', dest='ignore_case', action="store_true", default=False, help='case insensitive' ) parser.add_option( '-k', '--keep', dest='keep', action="store_true", default=False, help='' ) parser.add_option( '-d', '--debug', dest='debug', action='store_true', default=False, help='Turn on wrapper debugging to stdout' ) (options, args) = parser.parse_args() @@ -89,11 +90,15 @@ try: found = False search_string = line.split('\t')[incol].rstrip('\r\n') + if options.ignore_case: + search_string = search_string.upper() if options.debug: print >> sys.stderr, "search: %s" % (search_string) refFile = open(options.reference,'r') for tn,fline in enumerate(refFile): target_string = fline.split('\t')[refcol] + if options.ignore_case: + target_string = target_string.upper() if options.debug: print >> sys.stderr, "in: %s %s %s" % (search_string,search_string in target_string,target_string) if search_string in target_string: diff -r fe0327a3ba81 -r 856033fb26e8 find_in_reference.xml --- a/find_in_reference.xml Sat Jan 04 09:03:57 2014 -0500 +++ b/find_in_reference.xml Fri Jan 17 14:50:53 2014 -0600 @@ -7,6 +7,7 @@ --input_column $column.input_column --reference_column $column.reference_column #end if + $case_insensitive #if 'novel' in $outputs.__str__ or not 'found' in $outputs.__str__: --output "$novel" #end if @@ -16,9 +17,9 @@ + help="e.g. a peptide fasta converted to tabular"/> + help="e.g. a protein fasta converted to tabular"/> @@ -32,6 +33,7 @@ help=""/> + @@ -58,11 +60,34 @@ **Find in Reference** -Filters lines of a tabular input file by checking if the selected input column +Filters lines of a tabular input file by checking if the selected input column value is a substring of the selected column of any line in the reference file. This can be used to check if peptides sequences are present in a set of reference proteins, as a means of filtering out uninteresting peptide sequences. +For Example with:: + + Input + >pep1 LIL + >pep2 WTF + >pep3 ISK + + Reference + >prot1 RLET + >prot2 LLIL + >prot3 LAPSE + >prot3 RISKY + + The outputs + + Not found in reference + >pep2 WTF + + Found in reference + >pep1 LIL + >pep3 ISK + +