This does not "add to both ends", I think I need a little more information to do that.
Here's a solution that appends "N"s.
It's not R, it's an awk "one liner" (a long one liner) :
cat yourseqfile | awk '{ a[count++] = $0; if (length($0)>l)l=length($0) } END { for (i=0; i<count; i++) { printf("%s",a[i]); for (j=length(a[i]); j<l; j++) printf "N"; printf("\n"); } }'
example:
bash-3.2$ cat yourseqfile
START
A
ACGTACGTACGTACGTACGTACGT
ACGTACGTACGTAC
ACGT
DONE
bash-3.2$ cat yourseqfile | awk '{ a[count++] = $0; if (length($0)>l)l=length($0) } END { for (i=0; i<count; i++) { printf("%s",a[i]); for (j=length(a[i]); j<l; j++) printf "N"; printf("\n"); } }'
STARTNNNNNNNNNNNNNNNNNNN
NNNNNNNNNNNNNNNNNNNNNNNN
ANNNNNNNNNNNNNNNNNNNNNNN
ACGTACGTACGTACGTACGTACGT
ACGTACGTACGTACNNNNNNNNNN
ACGTNNNNNNNNNNNNNNNNNNNN
DONENNNNNNNNNNNNNNNNNNNN
Last edited by Richard Finney; 10-05-2018 at 07:18 AM.
|