Question: Problem To Convert Pdb Text File To Jmol Jar File
gravatar for Hazelin
9.8 years ago by
Hazelin100 wrote:

I have to read the co-ordinates of a 3D object from the text file that's from PDB and store it in an array and after storing the co-ordinates in the array, I need it to undergo some processes such as rotation & translation and finally, the final product would be a JAR file.

The trick here is that I need to store it in a JAR file so that I can view the final product in my visualizer (Jmol). How do I get about in doing that?

The following code here is the compression of a JAR file.

Is this of use?


 public class compress {
 public static void doit(
                        String filein, 
                        String fileout
                        ) {
  FileInputStream fis = null;
  FileOutputStream fos = null;
  try {
    fis = new FileInputStream(filein);
    fos = new FileOutputStream(fileout);
    ZipOutputStream zos =
        new ZipOutputStream(fos);
    ZipEntry ze = new ZipEntry(filein);
    final int BUFSIZ = 4096;
    byte inbuf[] = new byte[BUFSIZ];
    int n;
    while ((n = != -1)
      zos.write(inbuf, 0, n);
    fis = null;
    fos = null;
  catch (IOException e) {
  finally {
    try {
      if (fis != null)
      if (fos != null)
    catch (IOException e) {
public static void main(String args[]) {
if (args.length != 2) {
 System.err.println("missing filenames");
 if (args[0].equals(args[1])) {
 System.err.println("filenames are identical");
  doit(args[0], args[1]);

Your help is greatly appreciated! :D I need to do this program in JAVA.

conversion file format java pdb • 2.5k views
ADD COMMENTlink modified 20 months ago by RamRS27k • written 9.8 years ago by Hazelin100

I am sorry, but the question is not entirely clear to me... do I understand correctly that you like to rebuild the Jmol jar, to include one particular PDB entry?

ADD REPLYlink written 9.8 years ago by Egon Willighagen5.2k

Sorry for the lack of clarity. Actually, no. It's 2 PDB entries because I'm doing a superposition algorithm using JAVA. So the target will remain in array1 but the query in array2 will undergo transformation and so on, thus I need the final product/output to be shown in Jmol. Thank you!!

ADD REPLYlink written 9.8 years ago by Hazelin100

JAR files are used to package and distribute multiple java files as a single file. In fact they are nothing more than a zip archive with an extra directory in it. Therefore you would need to be a little more specific in just what type of JAR file you need.

ADD REPLYlink written 9.8 years ago by Istvan Albert ♦♦ 84k
gravatar for Jussi
9.8 years ago by
Jussi180 wrote:

I'm not sure did I understand your requirements properly, but I would use some build tool (Ant, for example). You can create the files in Java and add them to the jar using build tool you your choise. Ant has a "Jar" task that can create or update the jar file for you:

<jar destfile="${dist}/lib/app.jar" update="true">
    <fileset dir="${build}/classes"
<fileset dir="${src}/resources"/>


It is better to use existing implementation rather than creating your own. For example, you have lots of code handling exceptions and closing streams safely, but still your fos stream is never closed.

ADD COMMENTlink modified 20 months ago by RamRS27k • written 9.8 years ago by Jussi180
gravatar for Pierre Lindenbaum
9.8 years ago by
France/Nantes/Institut du Thorax - INSERM UMR1087
Pierre Lindenbaum128k wrote:

Not sure I understand what you want to be packaged.

However, see CreateJarfile here and the other samples about 'jar' here.

ADD COMMENTlink modified 20 months ago by RamRS27k • written 9.8 years ago by Pierre Lindenbaum128k
gravatar for Khader Shameer
9.8 years ago by
Manhattan, NY
Khader Shameer18k wrote:

I think it will good to add PDB files as such to 'resources' than converting PDB file to an object. I am afraid, if you convert PDB file to objects you again need to convert it back to native format before loading to JMol. And regarding the superposition part, as I explained in your earlier questions (1 and 2), you may perform the superposition part prior to load the PDB files to JMol.

ADD COMMENTlink modified 8 months ago by RamRS27k • written 9.8 years ago by Khader Shameer18k
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1130 users visited in the last hour