This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Trying to get a GREP of things...

Hi all,

First time poster, long time reader.

I have a list of genes in a .txt file. This is a simple column of all the genes I want to know more about I also have a flyBaseGene.txt file, a tab delimited file containing information like TSS start, stop, and all the other fun stuff. [My genes of interest match those in flybasegene by simple Ctrl+F]

I've tried for a while running the following command with some variations in Linux with no desired outcome.

grep -F Genes_of_interest.txt flyBaseGene.txt > Pleasework.txt

Please help!!11!11!1!!1!!!!!

gene grep awk
cat Genes_of_interest.txt | grep -e "$1" flyBaseGene.txt > results.txt

This gave me the flybasegene.txt file + the genes of interest listed at the bottom...

put this in bash script:

#!/usr/bin/bash

grep -e "$1" flyBaseGene.txt >> results.txt

save as grep_gene.sh, then:

cat Genes_of_interest.txt | xargs -n 1 bash grep_gene.sh

1 answer

you're using

   -F, --fixed-strings
          Interpret PATTERN as a  list  of  fixed  strings,  separated  by
          newlines,  any  of  which is to be matched.  (-F is specified by
          POSIX.)

you want

   -f FILE, --file=FILE
          Obtain  patterns  from  FILE,  one  per  line.   The  empty file
          contains zero patterns, and therefore matches nothing.   (-f  is
          specified by POSIX.)


grep -f Genes_of_interest.txt flyBaseGene.txt > Pleasework.txt

better than grep , use join:

join -t $'\t' -1 1 -2 1 <(sort -t $'\t' -k1,1 list1.txt)   <(sort -t $'\t' -k1,1 list2.txt)

"sort: cannot read: '\t': No such file or directory"

This didnt work :(

btw big fan of you

I have been trying to use various grep commands including like the one below

grep -f myID.txt info.txt > Pleasework.txt

However, i only get one match back (but I know there are more). The match is the last entry in the column.

myID text is: 150002986789 150076978692 etc in one column

The info.txt is various line with column seperated information: 15028374023487 1 2 4 father

Any pointers to what I am doing wrong thank you Julia

In case anyone has a similar problem, this worked for me:

grep -wFf <(sed 's/\r$//' file1.txt) file2.txt 

Log in to answer this question.