Question: Problem To Convert Pdb Text File To Jmol Jar File
4
gravatar for Hazelin
8.8 years ago by
Hazelin100
Singapore
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?

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

 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);
    zos.putNextEntry(ze);
    final int BUFSIZ = 4096;
    byte inbuf[] = new byte[BUFSIZ];
    int n;
    while ((n = fis.read(inbuf)) != -1)
      zos.write(inbuf, 0, n);
    fis.close();
    fis = null;
    zos.close();
    fos = null;
  }
  catch (IOException e) {
    System.err.println(e);
  }
  finally {
    try {
      if (fis != null)
        fis.close();
      if (fos != null)
        fos.close();
    }
    catch (IOException e) {
    }
  }
}
public static void main(String args[]) {
if (args.length != 2) {
 System.err.println("missing filenames");
 System.exit(1);
}
 if (args[0].equals(args[1])) {
 System.err.println("filenames are identical");
 System.exit(1);
  }
  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.3k views
ADD COMMENTlink modified 8 months ago by RamRS21k • written 8.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 8.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 8.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 8.8 years ago by Istvan Albert ♦♦ 80k
2
gravatar for Jussi
8.8 years ago by
Jussi180
Finland
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"
         excludes="**/Test.class"
    />
<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 8 months ago by RamRS21k • written 8.8 years ago by Jussi180
1
gravatar for Pierre Lindenbaum
8.8 years ago by
France/Nantes/Institut du Thorax - INSERM UMR1087
Pierre Lindenbaum120k 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 8 months ago by RamRS21k • written 8.8 years ago by Pierre Lindenbaum120k
1
gravatar for Khader Shameer
8.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 RamRS21k • written 8.8 years ago by Khader Shameer18k
Please log in to add an answer.

Help
Access

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