This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Download Fasta.Txt Of A Protein From Pdb Using Biojava

Hi.. I wanted to download fasta.txt of a protein from the protein data bank using biojava. I am successfully able to download the pdb.gz file of the protein using biojava but unable to do so for fasta.txt. is there any method that biojava offers to do this? Please help... I am still a newbie to biojava.. Thank you in advance

fasta pdb java biojava

It can be easily achieved using biopython or pymol scripting.

@Pappu: i need it in java... all the rest of my code are in java... so i was looking for something in java for this too..

Did you consider Jython?

@Pappu: the link you sent me above says cannot be opened because it is a local file.

This command will work in linux shell i.e. in bash.

2 answers

The best way to do this will depend on exactly what you want to fetch...

If you want all the chain sequences described in the structure (both protein and nucleotide), then a simple fetch from one of the Worldwide Protein Data Bank (wwPDB) sites will do the job, e.g. to get the sequences for PDB:10MH:

Sample Java code for fetching data from a web site can be found with an Internet search. FWIW the site I usually use to remind myself of the method specifics is part of the EMBL-EBI's Web Services tutorials, for example using java.net http://www.ebi.ac.uk/Tools/webservices/tutorials/06_programming/java/rest/java.net

If you want the sequence for a specific chain from a structure, then the EMBL-EBI's dbfetch and WSDbfetch services are an option. These know how to deal with common forms of structure and chain identifiers and the case sensitivity rules for the chain identifier. For details of the supported PDB identifier formats see: http://www.ebi.ac.uk/Tools/dbfetch/dbfetch/dbfetch.databases#pdb. They also support retrieval of all sequences for a structure, and if using the specific database names 'pdbaa' and 'pdbna' retrieval of only the protein or nucleotide sequences for a structure.

In BioJava you can also extract the ATOM and SEQRES chain sequences from the PDB structure, see:

i think this code is a demo, it should work with you

   import java.io.BufferedReader;
   import java.io.File;
   import java.io.FileOutputStream;
  import java.io.FileReader;

   import org.biojavax.Namespace;
   import org.biojavax.RichObjectFactory;
   import org.biojavax.bio.seq.RichSequence;
   import org.biojavax.bio.seq.RichSequenceIterator;



public class ReadWriteGES_BJ1_6{

public static void main(String[] args) {
    BufferedReader br = null;
    Namespace ns = null;
            //this path is used for destination file too
    String filePath= "/whereYourFileIs/sequences";
    String insdExt=".gbc";
    String fastaExt=".FASTA";


    try{
        br = new BufferedReader(new FileReader(filePath+insdExt));
        ns = RichObjectFactory.getDefaultNamespace();


             // You can use any of the convenience methods found in the BioJava 1.6 API
                    RichSequenceIterator rsi = RichSequence.IOTools.readINSDseqDNA(br, ns);

        // Since a single file can contain more than a sequence, you need to iterate over
        // rsi to get the information.
                    while (rsi.hasNext()) {
                        RichSequence seq = rsi.nextRichSequence();
                        RichSequence.IOTools.writeFasta(new 
                                     FileOutputStream(new File(filePath+fastaExt)), seq, ns);
                        System.out.println(
                                seq.toString() +
                                " has " + seq.countFeatures() + 
                                " features");
                    }

    }
    catch(Exception be){
        be.printStackTrace();
        System.exit(-1);
    }
}

}

for more you should refer to the BioJava CookBook Here

Hi! This code is not downloading a fasta file from protein data bank.

Log in to answer this question.