pcg
April 1, 2011, 9:53am
1
I have a master sequence say
>Seq
ATGCGTA.......
That I want to repeat N no of times and each time the sequence is the same but the header changes in incremental numerical order
E.g.
>Seq1
ATGCGTA.......
>Seq2
ATGCGTA.......
>Seq3
ATGCGTA.......
.
.
.
.
>SeqN
ATGCGTA.......
Ultimately the user decides on the value of N
Does anyone know a quick way of doing this
awk -v N=100 -v seq="ATGCGTA..." 'BEGIN{while(++i <= N)print "Seq" i RS seq}'
kurumi
April 1, 2011, 10:07am
3
$ num=10 #user input
$ ruby -e 'BEGIN{c=1;s=File.open("file").read};1.upto('$num'){|x| print s.gsub(/^>Seq/,">Seq#{c}");c+=1 }'
>Seq1
ATGCGTA.......
>Seq2
ATGCGTA.......
>Seq3
ATGCGTA.......
>Seq4
ATGCGTA.......
>Seq5
ATGCGTA.......
>Seq6
ATGCGTA.......
>Seq7
ATGCGTA.......
>Seq8
ATGCGTA.......
>Seq9
ATGCGTA.......
>Seq10
ATGCGTA.......
If your shell is ksh93
#!/bin/ksh93
NUM=100
for i in {1..$NUM}
do
printf "Seq%d\nATGCGTA......\n" $i
done
You can also use a sequence expression in bash but the value must be hardcoded into the sequence, i.e. {1..100}, because bash does not apply any syntatic interpretation to the content between the braces.