Menu

Unrecognized File Format for File Error

2015-08-08
2015-08-13
  • Gungor Budak

    Gungor Budak - 2015-08-08

    I'm trying to load a remote file in Amazon AWS S3 storage but it gives me following error:

    unrecognized file format for file
    http://storage.evias.s3.amazonaws.com/2Q7M.pdb

    error

    The file is available and everyone has permission to open/download it but JSMol can't recognize it. The error disappears and JSMol works fine if I put the file within the same server where I host JSMol.

    Am I doing something wrong? Because it can load the very same PDB file from PDB's website (http://www.rcsb.org/pdb/files/2Q7M.pdb). I checked mimetypes for each and they are the same:

    In [4]: import mimetypes

    In [5]: mimetypes.guess_type("http://www.rcsb.org/pdb/files/2Q7M.pdb")
    Out[5]: ('chemical/x-pdb', None)

    In [6]: mimetypes.guess_type("http://storage.evias.s3.amazonaws.com/2Q7M.pdb")
    Out[6]: ('chemical/x-pdb', None)

    In [7]:

    What could be wrong? I'd appreciate any help

    Thanks in advance

     
    • Bob Hanson

      Bob Hanson - 2015-08-08

      I had no problem with that in JSmol on my pages, either locally or using
      http://chemapps.stolaf.edu/jmol/jsmol/jsmol.htm

      See, for example:

      http://chemapps.stolaf.edu/jmol/jsmol/simple.htm?load%20load%20http://storage.evias.s3.amazonaws.com/2Q7M.pdb

      But not that in this case AJAX is using an relay server (Info.serverURL)
      which in my case goes to St. Olaf. Perhaps you have not got that set up.
      The issue is that the amazon storage site does not allow cross-domain AJAX
      calls. They are missing the required header:

      access-control-allow-origin: *

      So JSmol has to use a call to a server that allows that.

      Bob

      --
      Robert M. Hanson
      Larson-Anderson Professor of Chemistry
      Chair, Department of Chemistry
      St. Olaf College
      Northfield, MN
      http://www.stolaf.edu/people/hansonr

      If nature does not answer first what we want,
      it is better to take what answer we get.

      -- Josiah Willard Gibbs, Lecture XXX, Monday, February 5, 1900

       
      • Gungor Budak

        Gungor Budak - 2015-08-09

        Thanks for your reply Bob

        I actually set the serverURL but it wasn't an absolute path so for now I set it directly to St. Olaf's: http://chemapps.stolaf.edu/jmol/jsmol/php/jsmol.php

        Here is how I do my JS:


        <script type="text/javascript"><br> var title = "{{ receptor.title }}",<br> path = "http://storage.evias.s3.amazonaws.com/2Q7M.pdb",<br> serverURL = "http://chemapps.stolaf.edu/jmol/jsmol/php/jsmol.php",<br> j2sPath = "{% static "vst/js/jsmol/j2s" %}";<br> </script>

        And followed by (an external JS added to after above HTML):

        jmol_isReady = function(applet) {
        Jmol._getElement(applet, "appletdiv").style.border="1px solid #888";
        }
        var script = "set zoomlarge false;";
        var info = {
        width: "100%",
        height: "100%",
        debug: false,
        color: "#f1f1f1",
        addSelectionOptions: false,
        serverURL: serverURL,
        use: "HTML5",
        j2sPath: j2sPath,
        readyFunction: jmol_isReady,
        script: script,
        disableInitialConsole: true
        }
        $("#jsmol_container").html(Jmol.getAppletHtml("myJSmol", info));
        if (path.length > 0) {
        Jmol.loadFile(myJSmol, path);
        }

        And I still get the same error. I saw it works for you but do you do something else to make it work? What do I do wrong?

         

        Last edit: Gungor Budak 2015-08-10
        • Bob Hanson

          Bob Hanson - 2015-08-09

          Your error is indeed the cross-domain issue:

          Cross-Origin Request Blocked: The Same Origin Policy disallows reading the
          remote resource at http://storage.evias.s3.amazonaws.com/2Q7M.pdb. (Reason:
          CORS header 'Access-Control-Allow-Origin' missing).

          Try removing the "async" in your load command:

          load "http://storage.evias.s3.amazonaws.com/2Q7M.pdb"

          instead of

          load async "http://storage.evias.s3.amazonaws.com/2Q7M.pdb"

          The "async" option is not available when the server does not allow
          cross-domain access, it turns out. I had not realized that.

          BTW -- I think you have some sort of mix of files on your server. I got
          this error when I loaded the file into your page that way:

          [opened the Jmol JavaScript Console]

          $cache clear
          $set zoomlarge false;;;zap;set echo middle center;echo Retrieving
          data...;load "http://storage.evias.s3.amazonaws.com/2Q7M.pdb"

          Retrieving data...
          MEMBRANE PROTEIN, LIPID TRANSPORT 07-JUN-07 2Q7M
          CRYSTAL STRUCTURE OF HUMAN FLAP WITH MK-591
          found biomolecule 1: A, B, C
          found biomolecule 2: D, E, F

          *script ERROR: TypeError: JU.PT.isAI is not a function *

          [I see the structure loaded on your site]

          This indicates that some of the .js files on your system are from an
          earlier version of JSmol than the one used to load the file. I recommend
          re-uploading all the jsmol/j2s and jsmol/js files.

          On Sun, Aug 9, 2015 at 10:07 AM, Gungor Budak gungorbudak@users.sf.net
          wrote:

          Thanks for your reply Bob

          I actually set the serverURL but it wasn't an absolute path so for now I
          set it directly to St. Olaf's:
          http://chemapps.stolaf.edu/jmol/jsmol/php/jsmol.php

          Here is how I do my JS:

          <script type="text/javascript"><br> var title = "{{ receptor.title }}",<br> path = "http://storage.evias.s3.amazonaws.com/2Q7M.pdb",<br> serverURL = "http://chemapps.stolaf.edu/jmol/jsmol/php/jsmol.php",<br> j2sPath = "{% static "vst/js/jsmol/j2s" %}";<br> </script>

          And followed by (an external JS added to after above HTML):

          jmol_isReady = function(applet) {
          Jmol._getElement(applet, "appletdiv").style.border="1px solid #888";
          }
          var script = "set zoomlarge false;";
          var info = {
          width: "100%",
          height: "100%",
          debug: false,
          color: "#f1f1f1",
          addSelectionOptions: false,
          serverURL: serverURL,
          use: "HTML5",
          j2sPath: j2sPath,
          readyFunction: jmol_isReady,
          script: script,
          disableInitialConsole: true
          }
          $("#jsmol_container").html(Jmol.getAppletHtml("myJSmol", info));
          if (path.length > 0) {
          Jmol.loadFile(myJSmol, path);
          }

          And I still get the same error. I saw it works for you but do you do
          something else to make it work? Is what I do wrong? You can see the error
          here as well: http://evias.koding.io/tr/vst/receptors/4/


          Unrecognized File Format for File Error
          https://sourceforge.net/p/jsmol/discussion/general/thread/d500b3c9/?limit=25#a134/660f/ada0


          Sent from sourceforge.net because you indicated interest in
          https://sourceforge.net/p/jsmol/discussion/general/

          To unsubscribe from further messages, please visit
          https://sourceforge.net/auth/subscriptions/

          --
          Robert M. Hanson
          Larson-Anderson Professor of Chemistry
          Chair, Department of Chemistry
          St. Olaf College
          Northfield, MN
          http://www.stolaf.edu/people/hansonr

          If nature does not answer first what we want,
          it is better to take what answer we get.

          -- Josiah Willard Gibbs, Lecture XXX, Monday, February 5, 1900

           
          • Gungor Budak

            Gungor Budak - 2015-08-10

            Thank you ver much Bob. I re-uploaded the files and didn't use

            Jmol.loadFile(myJSmol, path);

            but used

            script += "load " + path;

            To get rid of that "async" (I gues Jmol.loadFile() puts it by default or there is an option to disable it but I don't know)

            Now it works!

             
            • Bob Hanson

              Bob Hanson - 2015-08-10

              Great. I have also fixed the LOAD ASYNC problem.

              On Mon, Aug 10, 2015 at 3:52 AM, Gungor Budak gungorbudak@users.sf.net
              wrote:

              Thank you ver much Bob. I re-uploaded the files and didn't use

              Jmol.loadFile(myJSmol, path);

              but used

              script += "load " + path;

              To get rid of that "async" (I gues Jmol.loadFile() puts it by default or
              there is an option to disable it but I don't know)

              Now it works!

              Unrecognized File Format for File Error
              https://sourceforge.net/p/jsmol/discussion/general/thread/d500b3c9/?limit=25#a134/660f/ada0/a9c4/ff79


              Sent from sourceforge.net because you indicated interest in
              https://sourceforge.net/p/jsmol/discussion/general/

              To unsubscribe from further messages, please visit
              https://sourceforge.net/auth/subscriptions/

              --
              Robert M. Hanson
              Larson-Anderson Professor of Chemistry
              Chair, Department of Chemistry
              St. Olaf College
              Northfield, MN
              http://www.stolaf.edu/people/hansonr

              If nature does not answer first what we want,
              it is better to take what answer we get.

              -- Josiah Willard Gibbs, Lecture XXX, Monday, February 5, 1900

               
              • Gungor Budak

                Gungor Budak - 2015-08-13

                How did you solve it? Shall I update my JSmol?

                I was experimenting SYNC way of getting data but it's super slow and it shows blank div for 10 seconds which is annoying

                I found out we can set up CORS like this and now I can load files using Jmol.loadFile()

                Go to your S3 bucket properties, and under "Permissions", click on "Add CORS Configuration". Paste this in:

                <CORSConfiguration>
                    <CORSRule>
                        <AllowedOrigin>*</AllowedOrigin>
                        <AllowedMethod>GET</AllowedMethod>
                        <MaxAgeSeconds>3000</MaxAgeSeconds>
                        <AllowedHeader>Authorization</AllowedHeader>
                    </CORSRule>
                </CORSConfiguration>
                

                from https://www.caktusgroup.com/blog/2014/11/10/Using-Amazon-S3-to-store-your-Django-sites-static-and-media-files/

                 

Log in to post a comment.