How to remove special characters from text files?
1
0
Entering edit mode
6.0 years ago

Hi all

I have an miRNA text file (having ~2000 miRNA information) like the following

>hsa-miR-576-3p MIMAT0004796
AAGAUGUGGAAAAAUUGGAAUC
>hsa-miR-140-5p MIMAT0000431
CAGUGGUUUUACCCUAUGGUAG

i want it to become

>hsa-miR-576-3p
 AAGAUGUGGAAAAAUUGGAAUC
>hsa-miR-140-5p
CAGUGGUUUUACCCUAUGGUAG

without the MIMAT000XX

Could anyone help me to do this? My OS is Ubuntu 14.04

Thank You in advance.

textfiles miRNAfiles ubuntu • 1.5k views
ADD COMMENT
1
Entering edit mode

Try sed ,

sed -e 's/MIMAT.*//' input.file > output.file
ADD REPLY
0
Entering edit mode

Thank You So Much kathirvel. I was able to do it.

ADD REPLY
0
Entering edit mode

After this when i was running miRDeep2.pl, i got this error

mkdir mirdeep_runs/run_13_12_2018_t_16_20_32
#testing input files
#testing input files
started: 16:20:33
sanity_check_mature_ref.pl /home/shanthi/Desktop/Nivya/miRBase/mature_human_miRNA1.fa
Error: problem with /home/shanthi/Desktop/Nivya/miRBase/mature_human_miRNA1.fa
Error in line 5.309: The sequence
contains characters others than [acgtunACGTUN]
Please check your file for the following issues:
I.  Sequences are allowed only to comprise characters [ACGTNacgtn].
II. Identifiers are not allowed to have withespaces.

Do you have any idea how to rectify this?

ADD REPLY
0
Entering edit mode

Don't ask unrelated/new questions in existing threads. Consider opening a new thread, if you are not able to find a previous answer by searching.

ADD REPLY
1
Entering edit mode
6.0 years ago

Assuming there is a whitespace before the part that you want to remove, you can do this:

$ cut -d " " -f1 input.fa > output.fa

cut selects the columns given with -f parameter. With -d " " we define a whitespace as a delimiter between two columns.

fin swimmer

ADD COMMENT
0
Entering edit mode

Thank you so much finswimmer.

ADD REPLY
0
Entering edit mode

If an answer was helpful, you should upvote it; if the answer resolved your question, you should mark it as accepted. You can accept more than one if they work.
Upvote|Bookmark|Accept

Please do the same for your previous posts as well.

ADD REPLY
0
Entering edit mode

I shall do it. Thank You.

ADD REPLY

Login before adding your answer.

Traffic: 1736 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6