0
$\begingroup$

I am trying to edit the "end" of my sequences in a GFF3 that contains 10000 sequences (so I do not want to do it manually). I want to add 30 residues to every single fragment. How can I do this?

Currently, I have a file that looks like this:

##gff-version 3
sp_P45452_MMP13_HUMAN   SignalP-5.0 signal_peptide  1   19  0.994300    .   .   .
sp_Q8R2H5_PHLD_RAT      SignalP-5.0 signal_peptide  1   23  0.986089    .   .   .

I would like to edit it so that it looks like this:

##gff-version 3
sp_P45452_MMP13_HUMAN   SignalP-5.0 signal_peptide  1   49  0.994300    .   .   .
sp_Q8R2H5_PHLD_RAT      SignalP-5.0 signal_peptide  1   53  0.986089    .   .   .

Thank you!

$\endgroup$

1 Answer 1

3
$\begingroup$

That's what awk excels at! Simply set the input (-F '\t') and output (-v OFS='\t') record field separators to tab, and add 30 to the value of the fifth field on lines that don't start with a #:

$ awk -F'\t' -v OFS='\t' '/^[^#]/{$5+=30}1' file.gtf 
##gff-version 3
sp_P45452_MMP13_HUMAN   SignalP-5.0 signal_peptide  1   19  30.9943 .   .   .
sp_Q8R2H5_PHLD_RAT  SignalP-5.0 signal_peptide  1   23  30.9861 .   .   .
$\endgroup$
2
  • $\begingroup$ yep this is the good stuff $\endgroup$
    – Pallie
    Commented Sep 16, 2021 at 13:50
  • $\begingroup$ Thank you so much! I am new to awk and this was super helpful! $\endgroup$
    – obsmith
    Commented Sep 16, 2021 at 13:51

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.