2
$\begingroup$

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";
$\endgroup$
  • 1
    $\begingroup$ your algorithm to create a file is not clear. please clear your question $\endgroup$ – Hossein Vatani Aug 3 '18 at 12:53
  • 1
    $\begingroup$ Don't you have some bioinformatics tool that filters GFF files on gene type? $\endgroup$ – Kusalananda Aug 3 '18 at 12:58
  • $\begingroup$ No, I dont have any. Are there any tools for filtering on gene_type? Could you please recommend me some. $\endgroup$ – user3351523 Aug 3 '18 at 13:00
  • $\begingroup$ @Kusalananda They mention that they want to keep "certain names of gene_type like only processed_pseudogene, lincRNA, unprocessed_pseudogene, antisense_RNA" $\endgroup$ – Sparhawk Aug 3 '18 at 13:05
  • $\begingroup$ @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. $\endgroup$ – Kusalananda Aug 3 '18 at 13:08
4
$\begingroup$
grep -E 'gene_type "(processed_pseudogene|lincRNA|unprocessed_pseudogene|antisense_RNA)";' input_file.txt

Explanation

  • grep -E: use extended regular expression so you don't need to escape things.
  • This kind of expression (foo|bar|baz) allows grep to include either of these strings. Hence, the total expression will match gene_type "processed_pseudogene";', gene_type "lincRNA";', etc.
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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