Hi, I have a problem with my codes now. I've actually extracted the column of information that I need from a text file. However, now I need to convert the output of the file to something that I specify, but I don't know how to do it.

It is actually changing the amino acid three-letter abbreviation to one-letter abbreviation.

Here are my codes:

import java.io.*;
import java.util.*;

public class ExtractAA {
	public static StringBuffer buffer;
 	public static BufferedReader input;
	public static void main(String[] args)
		int j=0, h=0, i=0;
		String[] counter3 = new String [10000];
		String[] counter4 = new String [10000];
		String[] counter1 = new String [10000];


      input = new BufferedReader(
      new FileReader( new File("D:\\project1\\Dynamic Programming\\Alignment Algorithms\\1a00.gz.txt") ) );		// input specified file
      String extract;
      while ( ( extract = input.readLine() ) != null ) 			//reading specified file
      	if ((extract.trim().startsWith("ATOM") && !extract.trim().endsWith("H"))) 		//extract lines that starts with ATOM AND end with anything but H
			StringTokenizer s = new StringTokenizer(extract," ");		//String tokenizer
      		int counter=0;
      		String ss = s.nextToken();
      		if (counter == 3) 						//extracts 3rd tokens of each line	
 			counter3[j] = ss;			
			if(counter == 4)						//extracts 4th tokens of each line
			counter4[h] = ss;     		
      	}// end of while(s.hasMoreTokens())

		    counter1[i] = counter3[j] +"\t"+ counter4[h];    

		    if (counter1[i].trim().startsWith("CA")) 
      		StringTokenizer a = new StringTokenizer(counter1[i],"\t");
      		int amino=0;
      			String aa = a.nextToken();
     			if (amino == 2)

      	         [B]char Ala = 'A';
		char Arg = 'R';
		char Asn = 'N';
		char Asp = 'D';
		char Cys = 'C';
		char Gln = 'Q';
		char Glu = 'E';
		char Gly = 'G';
		char His = 'H';
		char Ile = 'I';
		char Leu = 'L';
		char Lys = 'K';
		char Met = 'M';
		char Phe = 'F';
		char Pro = 'P';
		char Ser = 'S';
		char Thr = 'T';
		char Trp = 'W';
		char Tyr = 'Y';
		char Val = 'V';	[/B]		
      			}//end of while(a.hasMoreTokens())
      		}//end of if (counter1[i].trim().startsWith("CA"))	    	
      	}//end of if ((extract.trim().startsWith("ATOM") && !extract.trim().endsWith("H")))
      }//end of while ( ( extract = input.readLine() ) != null )
      }catch( IOException ioException ) {}
    }//end of main
}//end of public class

The output of the program is actually the three-letter abbreviation. However, I want to convert the output to one-letter abbreviation only, which is the bold part of the codes. May I know how to do it?

Have a look at HashMap. It will let you store the 3 letter abbreviation as a key and the one letter abbreviation as a value (map.put(key, vaue)), then it will give you an instant lookup of the vaLue associated with any key (value = map.get(key));

This question has already been answered. Start a new discussion instead.