This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How To Convert Gz File To Pdb Format?

Hi all when i downloaded the files from pdb's ftp site the format is in GZ. are there any ways that i can convert them to PDB format using java codes? Would be great if any of you can offer me your help and it will be much appreciated.

pdb java

2 answers

If you mean that the filename ends with ".gz", this is not a format. It means that the file is compressed (or "gzipped") using a utility named gzip.

If your OS has a terminal (Linux, OS X), simply uncompress using:

gunzip myfile.gz

If you want to use Java, here is one guide, or just Google search "gunzip java".

Based on your previous code, you could add a GZIPInputStream in your input stream to deflate the file on the fly, just like that:

import java.io.*;
import java.net.URL;
import java.util.zip.GZIPInputStream;

public class Ftp
    {
    public static void main(String[] args) {

        try{
           URL url =     new URL("ftp://ftp.wwpdb.org/pub/pdb/data/structures/all/pdb/pdb100d.ent.gz;type=i");
           InputStream in =     new BufferedInputStream(
        new GZIPInputStream(url.openStream()));
       byte buff[]=new byte[1024];
       int nRead;

           while((nRead=in.read(buff))!=-1)
        {
        System.out.write(buff,0,nRead);
        }
           in.close();
        } catch(Exception e)
        {
            e.printStackTrace();
        }   
    }   
}

but your problem is not really related to bioinformatics. You should rather ask this kind of question on StackOverflow.com.

And by the way, you already asked 3 questions on this site, and people gave you 3 valid answers. Please, validate those answers.

Why is this not bioinfo and writing a Perl script to detect three characters is??

Log in to answer this question.