Hi all, I'm having some problem with my codes. I have a output that is generated into a txt file. Now, I need to read the txt file and convert the output into something else.

This is the output that is store in a txt file:
VAL
LEU
SER
PRO
ALA
ASP
LYS
THR
ASN

They are all amino acid 3-letter abbreviation. I need to convert them into 1-letter abbreviation.

For example,
Val should be 'V'.
Leu should be 'L'.
Ser should be 'S'.
Pro should be 'P'.
Ala should be 'A'.
Asp should be 'D'.
Lys should be 'K'.
Thr should be 'T'.
Asn should be 'N'.

The final output should be only 1-letter abbreviation.

Like:
V
L
S
P
A
D
K
T
N

May I know how to do it?

First you have to read the file for that
Make a File object and read its contents using BufferedReaderObject.readLine();
this will return a string. with values VAL
LEU
SER
PRO
ALA
etc..

next is to convert this each valueinto corresponding letter by nested if conditions.

Continue this while(!feof())


+****************+
| new_programmer |
******************

HashMap (look it up in the API).
Add the 3 letter codes as keys and the 1 letter codes as values.
HashMap then does the lookup for you, value = map.get(key).

You can put the mapping in a text file and read from that file.
In this case, if you need to add new mapping, you don't have to change code.

HashMap (look it up in the API).
Add the 3 letter codes as keys and the 1 letter codes as values.
HashMap then does the lookup for you, value = map.get(key).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.