<p>I have a file with following information:</p>

<pre><code>chr1    HAVANA  gene    135141  135895  .       -       .       gene_id "ENSG00000268903.1"; gene_type "processed_pseudogene"; gene_name "AL627309.7"; level 2; havana_gene "OTTHUMG00000182518.2";
chr1    HAVANA  gene    137682  137965  .       -       .       gene_id "ENSG00000269981.1"; gene_type "processed_pseudogene"; gene_name "AL627309.8"; level 2; havana_gene "OTTHUMG00000182738.2";
chr1    HAVANA  gene    139790  140339  .       -       .       gene_id "ENSG00000239906.1"; gene_type "antisense_RNA"; gene_name "AL627309.2"; level 2; havana_gene "OTTHUMG00000002481.1";
chr1    HAVANA  gene    141474  173862  .       -       .       gene_id "ENSG00000241860.6"; gene_type "processed_transcript"; gene_name "AL627309.5"; level 2; tag "ncRNA_host"; havana_gene "OTTHUMG00000002480.3";
chr1    ENSEMBL gene    157784  157887  .       -       .       gene_id "ENSG00000222623.1"; gene_type "snRNA"; gene_name "RNU6-1100P"; level 3;
chr1    HAVANA  gene    160446  161525  .       +       .       gene_id "ENSG00000241599.1"; gene_type "lincRNA"; gene_name "AL627309.4"; level 2; havana_gene "OTTHUMG00000002525.1";
chr1    HAVANA  gene    182696  184174  .       +       .       gene_id "ENSG00000279928.2"; gene_type "unprocessed_pseudogene"; gene_name "FO538757.2"; level 2; havana_gene "OTTHUMG00000191962.1";
chr1    HAVANA  gene    185217  195411  .       -       .       gene_id "ENSG00000279457.4"; gene_type "unprocessed_pseudogene"; gene_name "FO538757.1"; level 2; havana_gene "OTTHUMG00000191963.1";
</code></pre>

<p>In the above file there is a <code>gene_type</code> with different names like processed_pseudogene, lincRNA, snRNA, unprocessed_pseudogene, antisense_RNA, processed_transcript.</p>

<p>I want to create a new file based on <code>gene_type</code>. Among all the gene_types I want the new file to be with certain names of <code>gene_type</code> like only processed_pseudogene, lincRNA, unprocessed_pseudogene, antisense_RNA.</p>

<p>The new file should look like below:</p>

<pre><code>chr1    HAVANA  gene    135141  135895  .       -       .       gene_id "ENSG00000268903.1"; gene_type "processed_pseudogene"; gene_name "AL627309.7"; level 2; havana_gene "OTTHUMG00000182518.2";
chr1    HAVANA  gene    137682  137965  .       -       .       gene_id "ENSG00000269981.1"; gene_type "processed_pseudogene"; gene_name "AL627309.8"; level 2; havana_gene "OTTHUMG00000182738.2";
chr1    HAVANA  gene    139790  140339  .       -       .       gene_id "ENSG00000239906.1"; gene_type "antisense_RNA"; gene_name "AL627309.2"; level 2; havana_gene "OTTHUMG00000002481.1";
chr1    HAVANA  gene    160446  161525  .       +       .       gene_id "ENSG00000241599.1"; gene_type "lincRNA"; gene_name "AL627309.4"; level 2; havana_gene "OTTHUMG00000002525.1";
chr1    HAVANA  gene    182696  184174  .       +       .       gene_id "ENSG00000279928.2"; gene_type "unprocessed_pseudogene"; gene_name "FO538757.2"; level 2; havana_gene "OTTHUMG00000191962.1";
chr1    HAVANA  gene    185217  195411  .       -       .       gene_id "ENSG00000279457.4"; gene_type "unprocessed_pseudogene"; gene_name "FO538757.1"; level 2; havana_gene "OTTHUMG00000191963.1";
</code></pre>

CC BY-SA 4.0
2018-08-03T12:58:18.490Z
Don't you have some bioinformatics tool that filters GFF files on gene type?
Kusalananda
CC BY-SA 4.0
2018-08-03T13:00:38.630Z
No, I dont have any. Are there any tools for filtering on gene_type? Could you please recommend me some.
stack_learner
CC BY-SA 4.0
2018-08-03T13:08:13.370Z
@Sparhawk Ah, they edited. I missed that. I still think it should be migrated though. I'm fairly certain there are standard bioinformatics tools for these types of operation on GFF files.
Kusalananda
CC BY-SA 4.0
2018-08-03T13:15:20.287Z
@Sparhawk There are mandatory and optional fields and there are controlled vocabularies for that 9th field, so it nat just "anything goes".
Kusalananda
<linux><shell>
How do I filter a GFF file by gene type?
# How do I filter a GFF file by gene type?

(Asked by: username_0 on 2018-08-03)

I have a file with following information:
chr1    HAVANA  gene    135141  135895  .       -       .       gene_id "ENSG00000268903.1"; gene_type "processed_pseudogene"; gene_name "AL627309.7"; level 2; havana_gene "OTTHUMG00000182518.2";
chr1    HAVANA  gene    137682  137965  .       -       .       gene_id "ENSG00000269981.1"; gene_type "processed_pseudogene"; gene_name "AL627309.8"; level 2; havana_gene "OTTHUMG00000182738.2";
chr1    HAVANA  gene    139790  140339  .       -       .       gene_id "ENSG00000239906.1"; gene_type "antisense_RNA"; gene_name "AL627309.2"; level 2; havana_gene "OTTHUMG00000002481.1";
chr1    HAVANA  gene    141474  173862  .       -       .       gene_id "ENSG00000241860.6"; gene_type "processed_transcript"; gene_name "AL627309.5"; level 2; tag "ncRNA_host"; havana_gene "OTTHUMG00000002480.3";
chr1    ENSEMBL gene    157784  157887  .       -       .       gene_id "ENSG00000222623.1"; gene_type "snRNA"; gene_name "RNU6-1100P"; level 3;
chr1    HAVANA  gene    160446  161525  .       +       .       gene_id "ENSG00000241599.1"; gene_type "lincRNA"; gene_name "AL627309.4"; level 2; havana_gene "OTTHUMG00000002525.1";
chr1    HAVANA  gene    182696  184174  .       +       .       gene_id "ENSG00000279928.2"; gene_type "unprocessed_pseudogene"; gene_name "FO538757.2"; level 2; havana_gene "OTTHUMG00000191962.1";
chr1    HAVANA  gene    185217  195411  .       -       .       gene_id "ENSG00000279457.4"; gene_type "unprocessed_pseudogene"; gene_name "FO538757.1"; level 2; havana_gene "OTTHUMG00000191963.1";

In the above file there is a gene_type with different names like processed_pseudogene, lincRNA, snRNA, unprocessed_pseudogene, antisense_RNA, processed_transcript.
I want to create a new file based on gene_type. Among all the gene_types I want the new file to be with certain names of gene_type like only processed_pseudogene, lincRNA, unprocessed_pseudogene, antisense_RNA.
The new file should look like below:
chr1    HAVANA  gene    135141  135895  .       -       .       gene_id "ENSG00000268903.1"; gene_type "processed_pseudogene"; gene_name "AL627309.7"; level 2; havana_gene "OTTHUMG00000182518.2";
chr1    HAVANA  gene    137682  137965  .       -       .       gene_id "ENSG00000269981.1"; gene_type "processed_pseudogene"; gene_name "AL627309.8"; level 2; havana_gene "OTTHUMG00000182738.2";
chr1    HAVANA  gene    139790  140339  .       -       .       gene_id "ENSG00000239906.1"; gene_type "antisense_RNA"; gene_name "AL627309.2"; level 2; havana_gene "OTTHUMG00000002481.1";
chr1    HAVANA  gene    160446  161525  .       +       .       gene_id "ENSG00000241599.1"; gene_type "lincRNA"; gene_name "AL627309.4"; level 2; havana_gene "OTTHUMG00000002525.1";
chr1    HAVANA  gene    182696  184174  .       +       .       gene_id "ENSG00000279928.2"; gene_type "unprocessed_pseudogene"; gene_name "FO538757.2"; level 2; havana_gene "OTTHUMG00000191962.1";
chr1    HAVANA  gene    185217  195411  .       -       .       gene_id "ENSG00000279457.4"; gene_type "unprocessed_pseudogene"; gene_name "FO538757.1"; level 2; havana_gene "OTTHUMG00000191963.1";

**Tags:** linux, shell
> **Comments:**
> **username_1**: Don't you have some bioinformatics tool that filters GFF files on gene type?  
> **username_0**: No, I dont have any. Are there any tools for filtering on gene_type? Could you please recommend me some.  
> **username_1**: @Sparhawk Ah, they edited. I missed that. I still think it should be migrated though. I'm fairly certain there are standard bioinformatics tools for these types of operation on GFF files.  
> **username_1**: @Sparhawk There are mandatory and optional fields and there are controlled vocabularies for that 9th field, so it nat just "anything goes".  

---

## 0 answers

