This is a test version of Biostars. For the public version, visit https://www.biostars.org.
To Parse A Fasta File And Retrieve Only The Raw Sequence Of A Specific Chain
import java.net.*;
import java.io.*;


public class Fasta {

    public static void main(String[] args) throws IOException 
    {
       URL url = new URL("http://www.rcsb.org/pdb/download/downloadFile.do?fileFormat=FASTA&compression=NO&structureId=1GJZ");
       URLConnection con = url.openConnection();
       InputStream is =con.getInputStream();
       BufferedReader br = new BufferedReader(new InputStreamReader(is));
       String line = null;
       while ((line = br.readLine()) != null) 
        {
         writeToFile(line);
        }
    } 
    public static void writeToFile(String text)
    {
        try 
        {
            BufferedWriter bw = new BufferedWriter(new FileWriter(new File("1GJZ.fasta.txt"), true));
            bw.write(text);
            bw.newLine();
            bw.close();
        }
        catch (Exception e) {}
    }
}

This is my code that will download the Fasta File of the id mentioned. I need to retrieve the raw sequence of only the A chain.

>1GJZ:A|PDBID|CHAIN|SEQUENCE
GSMQIFVKTLTGKTITLEVEPSDTIENVKAKIQDKEGIPPDQQRLIFAGKQLE
>1GJZ:B|PDBID|CHAIN|SEQUENCE
GSMQIFVKTLTGKTITLEVEPSDTIENVKAKIQDKEGIPPDQQRLIFAGKQLE

Please help me I am badly stuck here.

fasta java

If your sequences are spread only on one line, this could be easier approach: awk '/1GJZ:A/ { getline; print $0 }' input.fasta

I recommend you edit your post or title to indicate that you're interested in getting this information out of a PDB/3S structural file - would help make it clearer what kind of "chain" you're referring to

0 answers

No answers yet.

Log in to answer this question.