1
$\begingroup$

I have a text file with a list of name of genes (alias names) like this (** added for emphasis):

Solyc00g019980
**Solyc01g005020**
.. 
.

And i have a gff file like this:

SL4.0ch01   maker_ITAG  gene    46201   59605   .   -   .   ID=gene:Solyc01g005020.3;Alias=**Solyc01g005020**;Name=Solyc01g005020.3;length=13404
SL4.0ch01   maker_ITAG  mRNA    46201   59605   .   -   .   ID=mRNA:Solyc01g005020.3.1;Parent=gene:Solyc01g005020.3;Name=Solyc01g005020.3.1;Note=Salt Overly Sensitive 1;_AED=0.25;_QI=241|1|1|1|0|0|23|311|1151;_eAED=0.25;**Ontology_term=GO:0006812,GO:0015299,GO:0016021,GO:0055085**
SL4.0ch01   maker_ITAG  three_prime_UTR 46201   46511   .   -   .   ID=three_prime_UTR:Solyc01g005020.3.1.0;Parent=mRNA:Solyc01g005020.3.1
SL4.0ch01   maker_ITAG  exon    46201   46844   .   -   .   ID=exon:Solyc01g005020.3.1.1;Parent=mRNA:Solyc01g005020.3.1
SL4.0ch01   maker_ITAG  CDS 46512   46844   .   -   0   ID=CDS:Solyc01g005020.3.1.1;Parent=mRNA:Solyc01g005020.3.1
SL4.0ch01   maker_ITAG  exon    47281   47585   .   -   .   ID=exon:Solyc01g005020.3.1.2;Parent=mRNA:Solyc01g005020.3.1
SL4.0ch01   maker_ITAG  CDS 47281   47585   .   -   2   ID=CDS:Solyc01g005020.3.1.2;Parent=mRNA:Solyc01g005020.3.1
SL4.0ch01   maker_ITAG  exon    48276   48543   .   -   .   ID=exon:Solyc01g005020.3.1.3;Parent=mRNA:Solyc01g005020.3.1

I would like to grab only the ones i have in my list gene text file (Alias names) and the corresponding "Ontology_term" next to it.

Terminal is more convenient if there is a solution like grep or something.

Thanks in advance

edit: i would like to get this output, as an example

Solyc01g005070  Ontology_term=GO:0005543
Solyc01g005230  Ontology_term=GO:0008168

i dont mind if this is included "Ontology_term=", i would prefer not to be included though

thanks again

grep -f list.txt data.gff doesn't work for me, because it grabs all the other as well.

$\endgroup$
2
  • $\begingroup$ Are you trying to grep the Ontology term from the next line in your example? If so, that makes things a little more complicated. $\endgroup$
    – Ram RS
    Commented Mar 9, 2021 at 19:43
  • $\begingroup$ @JimHat your output example does not correspond to your input examples. Solyc01g005070 and Solyc01g005230 are not referred anywhere in your gff example. Thus, it's hard to relate exactly what you want exactly $\endgroup$
    – user324810
    Commented Mar 10, 2021 at 12:31

1 Answer 1

2
$\begingroup$

@Jim Hat

I took a stab at this given the example files you included.

If the 'list.txt' file looks like this:

Solyc00g019980
Solyc01g005020

And the data.gff file looks like this:

SL4.0ch01   maker_ITAG  gene    46201   59605   .   -   .   ID=gene:Solyc01g005020.3;Alias=Solyc01g005020;Name=Solyc01g005020.3;length=13404
SL4.0ch01   maker_ITAG  mRNA    46201   59605   .   -   .   ID=mRNA:Solyc01g005020.3.1;Parent=gene:Solyc01g005020.3;Name=Solyc01g005020.3.1;Note=Salt Overly Sensitive 1;_AED=0.25;_QI=241|1|1|1|0|0|23|311|1151;_eAED=0.25;Ontology_term=GO:0006812,GO:0015299,GO:0016021,GO:0055085
SL4.0ch01   maker_ITAG  three_prime_UTR 46201   46511   .   -   .   ID=three_prime_UTR:Solyc01g005020.3.1.0;Parent=mRNA:Solyc01g005020.3.1
SL4.0ch01   maker_ITAG  exon    46201   46844   .   -   .   ID=exon:Solyc01g005020.3.1.1;Parent=mRNA:Solyc01g005020.3.1
SL4.0ch01   maker_ITAG  CDS 46512   46844   .   -   0   ID=CDS:Solyc01g005020.3.1.1;Parent=mRNA:Solyc01g005020.3.1
SL4.0ch01   maker_ITAG  exon    47281   47585   .   -   .   ID=exon:Solyc01g005020.3.1.2;Parent=mRNA:Solyc01g005020.3.1
SL4.0ch01   maker_ITAG  CDS 47281   47585   .   -   2   ID=CDS:Solyc01g005020.3.1.2;Parent=mRNA:Solyc01g005020.3.1
SL4.0ch01   maker_ITAG  exon    48276   48543   .   -   .   ID=exon:Solyc01g005020.3.1.3;Parent=mRNA:Solyc01g005020.3.1

(Note I removed the **s, which I assumed were added for emphasis)

You can do the following:

aliasNames=$(grep -f list.txt data.gff | cut -d':' -f2 | cut -d';' -f1)
ontologyTerms=$(grep -f list.txt data.gff | cut -d';' -f 8 | cut -d'=' -f2)
paste <(echo "$aliasNames") <(echo "$ontologyTerms")

The first line filters the file based on your list and then extracts the alias names from the filtered GFF file. The second line filters the GFF and extracts the ontology terms (after the equal sign). And the third line joins the two as columns.

The result that is printed to the screen is:

Solyc01g005020.3
Solyc01g005020.3.1      GO:0006812,GO:0015299,GO:0016021,GO:0055085
Solyc01g005020.3.1.0
Solyc01g005020.3.1.1
Solyc01g005020.3.1.1
Solyc01g005020.3.1.2
Solyc01g005020.3.1.2
Solyc01g005020.3.1.3

Given the examples you included all of the lines of the GFF are included, but not all have gene ontology information.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.