Replace lowercase characters with -
Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
I have an output from vcfutils.pl vcf2fq with specified minimal depth, and it means that nucleotides with not enough depth are lowercase.
I would like to change them to gaps. I could do it in higher language but I would like to know the solution in bash.
I have found simple solution to replace all lowercase to uppercase:
awk 'BEGINFS=" "if(!/>/)print toupper($0)elseprint $1' in.fna > out.fna
but I would like to replace lowercase with -. The first row need to be omitted. Could you help me? Thanks
bash shell
New contributor
add a comment |Â
up vote
1
down vote
favorite
I have an output from vcfutils.pl vcf2fq with specified minimal depth, and it means that nucleotides with not enough depth are lowercase.
I would like to change them to gaps. I could do it in higher language but I would like to know the solution in bash.
I have found simple solution to replace all lowercase to uppercase:
awk 'BEGINFS=" "if(!/>/)print toupper($0)elseprint $1' in.fna > out.fna
but I would like to replace lowercase with -. The first row need to be omitted. Could you help me? Thanks
bash shell
New contributor
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I have an output from vcfutils.pl vcf2fq with specified minimal depth, and it means that nucleotides with not enough depth are lowercase.
I would like to change them to gaps. I could do it in higher language but I would like to know the solution in bash.
I have found simple solution to replace all lowercase to uppercase:
awk 'BEGINFS=" "if(!/>/)print toupper($0)elseprint $1' in.fna > out.fna
but I would like to replace lowercase with -. The first row need to be omitted. Could you help me? Thanks
bash shell
New contributor
I have an output from vcfutils.pl vcf2fq with specified minimal depth, and it means that nucleotides with not enough depth are lowercase.
I would like to change them to gaps. I could do it in higher language but I would like to know the solution in bash.
I have found simple solution to replace all lowercase to uppercase:
awk 'BEGINFS=" "if(!/>/)print toupper($0)elseprint $1' in.fna > out.fna
but I would like to replace lowercase with -. The first row need to be omitted. Could you help me? Thanks
bash shell
bash shell
New contributor
New contributor
New contributor
asked 7 hours ago
robinj
62
62
New contributor
New contributor
add a comment |Â
add a comment |Â
3 Answers
3
active
oldest
votes
up vote
3
down vote
The following sed
command will do the trick.
sed -e '/^[^>]/ s/[a-z]/-/g' in.fna > out.fna
Lines starting with >
will be escaped and the lowercase characters will be replaced with -
.
add a comment |Â
up vote
2
down vote
You could try it with sed
.
Replace all lower-case chars with -
in lines not starting with >
:
sed -e '/^>/!s/[a-z]/-/g' in.fa
add a comment |Â
up vote
1
down vote
You can also use this solution where tr command from linux can solve your problem:
tail -n +2 in.fna | tr '[:lower:]' '-'
add a comment |Â
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
The following sed
command will do the trick.
sed -e '/^[^>]/ s/[a-z]/-/g' in.fna > out.fna
Lines starting with >
will be escaped and the lowercase characters will be replaced with -
.
add a comment |Â
up vote
3
down vote
The following sed
command will do the trick.
sed -e '/^[^>]/ s/[a-z]/-/g' in.fna > out.fna
Lines starting with >
will be escaped and the lowercase characters will be replaced with -
.
add a comment |Â
up vote
3
down vote
up vote
3
down vote
The following sed
command will do the trick.
sed -e '/^[^>]/ s/[a-z]/-/g' in.fna > out.fna
Lines starting with >
will be escaped and the lowercase characters will be replaced with -
.
The following sed
command will do the trick.
sed -e '/^[^>]/ s/[a-z]/-/g' in.fna > out.fna
Lines starting with >
will be escaped and the lowercase characters will be replaced with -
.
answered 6 hours ago
arupgsh
430111
430111
add a comment |Â
add a comment |Â
up vote
2
down vote
You could try it with sed
.
Replace all lower-case chars with -
in lines not starting with >
:
sed -e '/^>/!s/[a-z]/-/g' in.fa
add a comment |Â
up vote
2
down vote
You could try it with sed
.
Replace all lower-case chars with -
in lines not starting with >
:
sed -e '/^>/!s/[a-z]/-/g' in.fa
add a comment |Â
up vote
2
down vote
up vote
2
down vote
You could try it with sed
.
Replace all lower-case chars with -
in lines not starting with >
:
sed -e '/^>/!s/[a-z]/-/g' in.fa
You could try it with sed
.
Replace all lower-case chars with -
in lines not starting with >
:
sed -e '/^>/!s/[a-z]/-/g' in.fa
edited 5 hours ago
Llopis
2,5471628
2,5471628
answered 6 hours ago
Peter Menzel
1137
1137
add a comment |Â
add a comment |Â
up vote
1
down vote
You can also use this solution where tr command from linux can solve your problem:
tail -n +2 in.fna | tr '[:lower:]' '-'
add a comment |Â
up vote
1
down vote
You can also use this solution where tr command from linux can solve your problem:
tail -n +2 in.fna | tr '[:lower:]' '-'
add a comment |Â
up vote
1
down vote
up vote
1
down vote
You can also use this solution where tr command from linux can solve your problem:
tail -n +2 in.fna | tr '[:lower:]' '-'
You can also use this solution where tr command from linux can solve your problem:
tail -n +2 in.fna | tr '[:lower:]' '-'
answered 4 hours ago
Ammar Sabir Cheema
548213
548213
add a comment |Â
add a comment |Â
robinj is a new contributor. Be nice, and check out our Code of Conduct.
robinj is a new contributor. Be nice, and check out our Code of Conduct.
robinj is a new contributor. Be nice, and check out our Code of Conduct.
robinj is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fbioinformatics.stackexchange.com%2fquestions%2f5380%2freplace-lowercase-characters-with%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password