Trying to get a GREP of things...
1
0
Entering edit mode
7.0 years ago
Hushus ▴ 20

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 • 2.1k views
ADD COMMENT
0
Entering edit mode
cat Genes_of_interest.txt | grep -e "$1" flyBaseGene.txt > results.txt
ADD REPLY
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode

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
ADD REPLY
1
Entering edit mode
7.0 years ago

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
ADD COMMENT
0
Entering edit mode

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)
ADD REPLY
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode

This didnt work :(

btw big fan of you

ADD REPLY
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode

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

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

Login before adding your answer.

Traffic: 1692 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6