awk to supress error message with custom text

After a bash function is run the below file is produced:

out_name.txt tab-delimeted

Input    Errors and warnings    AccNo    Genesymbol    Variant    Reference Sequence Start Descr.    Coding DNA Descr.    Protein Descr.    GeneSymbol Coding DNA Descr.    GeneSymbol Protein Descr.    Genomic Reference    Coding Reference    Protein Reference    Affected Transcripts    Affected Proteins    Restriction Sites Created    Restriction Sites Deleted
NM_003924.3:c.242-1G>A    (variantchecker): Intronic position given for a non-genomic reference sequence.    
NM_003924.3:c.*18_*19delGCinsAA        NM_003924.3    PHOX2B_v001    c.*18_*19delGCinsAA    n.1323_1324delinsAA    c.*18_*19delinsAA    p.(=)    PHOX2B_v001:c.*18_*19delinsAA    PHOX2B_v001:p.(=)        NM_003924.3    NP_003915.2    NM_003924.3(PHOX2B_v001):c.*18_*19delinsAA    NM_003924.3(PHOX2B_i001):p.(=)    HpyAV        
NM_003924.3:c.013G>T        NM_003924.3    PHOX2B_v001    c.013G>T    n.373G>T    c.13G>T    p.(Glu5*)    PHOX2B_v001:c.13G>T    PHOX2B_v001:p.(Glu5*)        NM_003924.3    NP_003915.2    NM_003924.3(PHOX2B_v001):c.13G>T    NM_003924.3(PHOX2B_i001):p.(Glu5*)            

I am trying to add a condition that will suppress the warning message produced if $2 is
(variantchecker): Intronic position given for a non-genomic reference sequence. ,
In addition, that the $1 string "is an intronic variant" is displayed instead of the waring. My 2nd attempt to incorporate these changes is below,
which executes but nothing results. Thank you :).

desired result

NM_003924.3:c.242-1G>A is an intronic variant

awk

while read LINE; do
    awk -F'\t' '$2 == "variantchecker): Intronic position given for a non-genomic reference sequence." {print $1 && "is an intronic variant"}' 2>/dev/null
done < out_name.txt
print $1 && "is an intronic variant" | "cat 1>&2"
1 Like

Hello cmccabe,

String variantchecker): Intronic position given for a non-genomic reference sequence. will NOT be considered as a 2nd field because you have set the field separator as default which will be space and in above string we have many spaces, so condition with $2=="above_string" will NOT be TRUE.
Could you please try following and let me know if this helps.

awk '/variantchecker): Intronic position given for a non-genomic reference sequence./{print $1 " is an intronic variant."}'   Input_file

Thanks,
R. Singh

1 Like

Thank you both very much :).