Announcement

Collapse
No announcement yet.
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • parsing gff3 from NCBI

    Hi,

    I need some help parsing a gff3 file. Essentially, I am trying to pull out specific fields out of the info section using awk. I can't simply use the column arrangement because the lines do not all have the same info in them so I need to do a match. Here are a couple of lines from the file:

    HTML Code:
    NC_015011.2     Gnomon  gene    18691   26481   .       +       .       ID=gene0;Dbxref=GeneID:100538868;Name=LOC100538868;gbkey=Gene;gene=LOC100538868;partial=true;start_range=.,18691
    NC_015011.2     Gnomon  mRNA    18691   26481   .       +       .       ID=rna0;Parent=gene0;Dbxref=GeneID:100538868,Genbank:XM_010707932.1;Name=XM_010707932.1;gbkey=mRNA;gene=LOC100538868;partial=true;product=hematopoietic lineage cell-specific protein-like;start_range=.,18691;transcript_id=XM_010707932.1
    NC_015011.2     Gnomon  exon    18691   18743   .       +       .       ID=id1;Parent=rna0;Dbxref=GeneID:100538868,Genbank:XM_010707932.1;gbkey=mRNA;gene=LOC100538868;partial=true;product=hematopoietic lineage cell-specific protein-like;start_range=.,18691;transcript_id=XM_010707932.1
    NC_015011.2     Gnomon  exon    18865   18994   .       +       .       ID=id2;Parent=rna0;Dbxref=GeneID:100538868,Genbank:XM_010707932.1;gbkey=mRNA;gene=LOC100538868;partial=true;product=hematopoietic lineage cell-specific protein-like;transcript_id=XM_010707932.1
    What I am doing is using awk to pull out the last field, i.e. $9, substitute tabs for semicolons, then further parse using a match function to get the fields I want. The issue is that my printf does not seem to be printing only my matching fields. Here is what I have:

    Code:
    awk -F "\t" '{ print $9 }' mga_ref_Turkey_5.0_NCBI_FINAL_no_GI_no_region.gff3.txt | grep product | awk -F ";" '{ gsub(";","\t",$0);print $0 }' | awk -F "\t" '{for(i=0;i<NF;i++){if($i~/gene\=/){printf $i};if($i~/product\=/){printf $i }}printf "\n"}' | head
    My output looks like :

    HTML Code:
    ID=rna0	Parent=gene0	Dbxref=GeneID:100538868,Genbank:XM_010707932.1	Name=XM_010707932.1	gbkey=mRNA	gene=LOC100538868	partial=true	product=hematopoietic lineage cell-specific protein-like	start_range=.,18691	transcript_id=XM_010707932.1ID=rna0	Parent=gene0	Dbxref=GeneID:100538868,Genbank:XM_010707932.1	Name=XM_010707932.1	gbkey=mRNA	gene=LOC100538868	partial=true	product=hematopoietic lineage cell-specific protein-like	start_range=.,18691	transcript_id=XM_010707932.1gene=LOC100538868product=hematopoietic lineage cell-specific protein-like
    ID=id1	Parent=rna0	Dbxref=GeneID:100538868,Genbank:XM_010707932.1	gbkey=mRNA	gene=LOC100538868	partial=true	product=hematopoietic lineage cell-specific protein-like	start_range=.,18691	transcript_id=XM_010707932.1ID=id1	Parent=rna0	Dbxref=GeneID:100538868,Genbank:XM_010707932.1	gbkey=mRNA	gene=LOC100538868	partial=true	product=hematopoietic lineage cell-specific protein-like	start_range=.,18691	transcript_id=XM_010707932.1gene=LOC100538868product=hematopoietic lineage cell-specific protein-like
    ID=id2	Parent=rna0	Dbxref=GeneID:100538868,Genbank:XM_010707932.1	gbkey=mRNA	gene=LOC100538868	partial=true	product=hematopoietic lineage cell-specific protein-like	transcript_id=XM_010707932.1ID=id2	Parent=rna0	Dbxref=GeneID:100538868,Genbank:XM_010707932.1	gbkey=mRNA	gene=LOC100538868	partial=true	product=hematopoietic lineage cell-specific protein-like	transcript_id=XM_010707932.1gene=LOC100538868product=hematopoietic lineage cell-specific protein-like
    OK, so it looks like it works up to the last awk, i.e. if I change the last awk to print $3, I get the expected result, what doesn't seem to be happening is my match is not printing ONLY the matching field. What am I doing wrong in my last awk such that it isn't printing the $i that gets the match???

  • #2
    OK, figured it out. I should start my loop at 1, not 0. !!

    Comment

    Latest Articles

    Collapse

    • seqadmin
      Advanced Tools Transforming the Field of Cytogenomics
      by seqadmin


      At the intersection of cytogenetics and genomics lies the exciting field of cytogenomics. It focuses on studying chromosomes at a molecular scale, involving techniques that analyze either the whole genome or particular DNA sequences to examine variations in structure and behavior at the chromosomal or subchromosomal level. By integrating cytogenetic techniques with genomic analysis, researchers can effectively investigate chromosomal abnormalities related to diseases, particularly...
      09-26-2023, 06:26 AM
    • seqadmin
      How RNA-Seq is Transforming Cancer Studies
      by seqadmin



      Cancer research has been transformed through numerous molecular techniques, with RNA sequencing (RNA-seq) playing a crucial role in understanding the complexity of the disease. Maša Ivin, Ph.D., Scientific Writer at Lexogen, and Yvonne Goepel Ph.D., Product Manager at Lexogen, remarked that “The high-throughput nature of RNA-seq allows for rapid profiling and deep exploration of the transcriptome.” They emphasized its indispensable role in cancer research, aiding in biomarker...
      09-07-2023, 11:15 PM

    ad_right_rmr

    Collapse

    News

    Collapse

    Topics Statistics Last Post
    Started by seqadmin, Yesterday, 09:36 AM
    0 responses
    8 views
    0 likes
    Last Post seqadmin  
    Started by seqadmin, 10-02-2023, 07:14 AM
    0 responses
    15 views
    0 likes
    Last Post seqadmin  
    Started by seqadmin, 09-29-2023, 09:38 AM
    0 responses
    16 views
    0 likes
    Last Post seqadmin  
    Started by seqadmin, 09-27-2023, 06:57 AM
    0 responses
    16 views
    0 likes
    Last Post seqadmin  
    Working...
    X