Answers.Body: <p>It looks as though the script is looking for a URL (fastaURL) so you could try specifying the file as file://directory/test.fasta</p>
  
  <p>By default though, javascript cannot read local files from disk for security reasons. Are you sure it is even possible to specify a local file in your script in this way?  If yes, then the problem is likely that you need to specify the path correctly.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-04-29T15:44:12.040Z
Answers.Text: Thanks for the comment.  I tried specifying the file as you suggested, but no luck.  Perhaps it is the JavaScript limitation.  I suppose I respect why that design decision is made, but for in internal use only purpose, it seems limiting.
Answers.UserDisplayName: KirkD-CO
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-04-29T19:25:59.257Z
Answers.Text: One way to get round it is to host the web page and the FASTA file together in your own local webserver directory.  OSX has a built in local webserver that you can switch on without too much difficulty - then open the page from your browser using http://localhost/test.html   You would then be able to refer to the FASTA file as test.fasta as your script does now (URL relative to the calling page).
Answers.UserDisplayName: Jay Moore
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-05-10T04:22:56.820Z
Answers.Text: That did the trick.  Both files must be on a server and it does indeed work.
Answers.UserDisplayName: KirkD-CO
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-04-29T13:27:14.143Z
Answers.LastActivityDate: 2019-04-29T13:27:14.143Z
Answers.UserDisplayName: Jay Moore
Answers.Body: <p>just stumbled on this.  I'm the developer of igv.js.  Please feel free to open issues and questions on our git forum,  I don't often have time to browse other forums.</p>
  
  <p>Browsers will not allow loading of local files by file path in javascript, if they did it would be a gigantic security hole.  This restriction includes "file://" urls.  Local files can be loaded by user action (clicking a button),  that is supported in igv.js but there is no button for it as igv.js is designed as a component to embed in pages, not an application by itself.  For an example see igv.org/app (<a href="https://github.com/igvteam/igv-webapp" rel="nofollow noreferrer">https://github.com/igvteam/igv-webapp</a>),  a minimal application wrapping igv.js.  You'll find "local file" options for genomes and tracks there. </p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-10-30T05:41:52.877Z
Answers.LastActivityDate: 2019-10-30T05:41:52.877Z
Answers.UserDisplayName: Jim Robinson
Body: <p>I'm trying to use igv.js for a very simple visualization of some genomic alignments, but I can't get past the first step.  I have a FASTA file that I want to use as the reference, but igv.js consistently gives an error when I try to load that file.  The file is a valid FASTA (have tested others from other sources to be sure - same error), and I can specify a remote https:// file, but not a local file.</p>
  
  <p>Here's the HTML page I'm working on:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang="en"&gt;
  
  &lt;head&gt;
      &lt;meta charset="UTF-8"&gt;
      &lt;meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"&gt;
  
      &lt;title&gt;Local FASTA Test&lt;/title&gt;
  
      &lt;!-- IGV JS--&gt;
      &lt;script src="https://igv.org/web/release/2.1.0/dist/igv.min.js"&gt;&lt;/script&gt;
  
  &lt;/head&gt;
  
  &lt;body&gt;
  
      &lt;h1&gt;Local File Test&lt;/h1&gt;
  
      &lt;div id="igv-div" style="padding-top: 10px;padding-bottom: 10px; border:1px solid lightgray"&gt;&lt;/div&gt;
  
      &lt;script type="text/javascript"&gt;
          var igvDiv = document.getElementById("igv-div");
          var options = {
              reference: {
                  fastaURL: "test.fasta"
              }
          };
  
          igv.createBrowser(igvDiv, options)
              .then(function(browser) {
                  console.log("Created IGV browser");
              })
      &lt;/script&gt;
  
  &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>
  
  <p>and here's the FASTA file</p>
  
  <pre><code>&gt;HSBGPG Human gene for bone gla protein (BGP)
  GGCAGATTCCCCCTAGACCCGCCCGCACCATGGTCAGGCATGCCCCTCCTCATCGCTGGGCACAGCCCAGAGGGT
  ATAAACAGTGCTGGAGGCTGGCGGGGCAGGCCAGCTGAGTCCTGAGCAGCAGCCCAGCGCAGCCACCGAGACACC
  ATGAGAGCCCTCACACTCCTCGCCCTATTGGCCCTGGCCGCACTTTGCATCGCTGGCCAGGCAGGTGAGTGCCCC
  CACCTCCCCTCAGGCCGCATTGCAGTGGGGGCTGAGAGGAGGAAGCACCATGGCCCACCTCTTCTCACCCCTTTG
  GCTGGCAGTCCCTTTGCAGTCTAACCACCTTGTTGCAGGCTCAATCCATTTGCCCCAGCTCTGCCCTTGCAGAGG
  GAGAGGAGGGAAGAGCAAGCTGCCCGAGACGCAGGGGAAGGAGGATGAGGGCCCTGGGGATGAGCTGGGGTGAAC
  CAGGCTCCCTTTCCTTTGCAGGTGCGAAGCCCAGCGGTGCAGAGTCCAGCAAAGGTGCAGGTATGAGGATGGACC
  TGATGGGTTCCTGGACCCTCCCCTCTCACCCTGGTCCCTCAGTCTCATTCCCCCACTCCTGCCACCTCCTGTCTG
  GCCATCAGGAAGGCCAGCCTGCTCCCCACCTGATCCTCCCAAACCCAGAGCCACCTGATGCCTGCCCCTCTGCTC
  CACAGCCTTTGTGTCCAAGCAGGAGGGCAGCGAGGTAGTGAAGAGACCCAGGCGCTACCTGTATCAATGGCTGGG
  GTGAGAGAAAAGGCAGAGCTGGGCCAAGGCCCTGCCTCTCCGGGATGGTCTGTGGGGGAGCTGCAGCAGGGAGTG
  GCCTCTCTGGGTTGTGGTGGGGGTACAGGCAGCCTGCCCTGGTGGGCACCCTGGAGCCCCATGTGTAGGGAGAGG
  AGGGATGGGCATTTTGCACGGGGGCTGATGCCACCACGTCGGGTGTCTCAGAGCCCCAGTCCCCTACCCGGATCC
  CCTGGAGCCCAGGAGGGAGGTGTGTGAGCTCAATCCGGACTGTGACGAGTTGGCTGACCACATCGGCTTTCAGGA
  GGCCTATCGGCGCTTCTACGGCCCGGTCTAGGGTGTCGCTCTGCTGGCCTGGCCGGCAACCCCAGTTCTGCTCCT
  CTCCAGGCACCCTTCTTTCCTCTTCCCCTTGCCCTTGCCCTGACCTCCCAGCCCTATGGATGTGGGGTCCCCATC
  ATCCCAGCTGCTCCCAAATAAACTCCAGAAG
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-04-28T04:29:25.813Z
Comments.Text: Welcome to the site.  Have you reached to the IGV.js developers?  What is the "error" that you get
Comments.UserDisplayName: Bioathlete
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-04-28T13:21:31.370Z
Comments.Text: I have not reached out to the developers - I want sure where to do that.  The error says "cannot find chromosomename of undefined" or something similar.  The key being "undefined"which I interpret as, it did not load the specified file.
Comments.UserDisplayName: KirkD-CO
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-04-29T15:44:36.807Z
Comments.Text: The exact error I get is a dialog box stating:  Cannot read property 'getHomeChromosomeName' of undefined
Comments.UserDisplayName: KirkD-CO
Tags: <visualization><igv>
Title: Loading local FASTA file in igv.js
ThreadText: # Loading local FASTA file in igv.js
  
  (Asked by: username_0 on 2019-04-26)
  
  I'm trying to use igv.js for a very simple visualization of some genomic alignments, but I can't get past the first step. I have a FASTA file that I want to use as the reference, but igv.js consistently gives an error when I try to load that file. The file is a valid FASTA (have tested others from other sources to be sure - same error), and I can specify a remote https:// file, but not a local file.
  
  Here's the HTML page I'm working on:
  
  ```
  <!DOCTYPE html>
  <html lang="en">
  
  <head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
  
      <title>Local FASTA Test</title>
  
      <!-- IGV JS-->
      <script src="https://igv.org/web/release/2.1.0/dist/igv.min.js"></script>
  
  </head>
  
  <body>
  
      <h1>Local File Test</h1>
  
      <div id="igv-div" style="padding-top: 10px;padding-bottom: 10px; border:1px solid lightgray"></div>
  
      <script type="text/javascript">
          var igvDiv = document.getElementById("igv-div");
          var options = {
              reference: {
                  fastaURL: "test.fasta"
              }
          };
  
          igv.createBrowser(igvDiv, options)
              .then(function(browser) {
                  console.log("Created IGV browser");
              })
      </script>
  
  </body>
  
  </html>
  
  ```
  
  and here's the FASTA file
  
  ```
  >HSBGPG Human gene for bone gla protein (BGP)
  GGCAGATTCCCCCTAGACCCGCCCGCACCATGGTCAGGCATGCCCCTCCTCATCG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TTCTGCTCCT
  CTCCAGGCACCCTTCTTTCCTCTTCCCCTTGCCCTTGCCCTGACCTCCCAGCCCTATGGATGTGGGGTCCCCATC
  ATCCCAGCTGCTCCCAAATAAACTCCAGAAG
  
  ```
  
  **Tags:** visualization, igv
  
  > **Comments:**
  > **username_1**: Welcome to the site.  Have you reached to the IGV.js developers?  What is the "error" that you get  
  > **username_0**: I have not reached out to the developers - I want sure where to do that.  The error says "cannot find chromosomename of undefined" or something similar.  The key being "undefined"which I interpret as, it did not load the specified file.  
  > **username_0**: The exact error I get is a dialog box stating:  Cannot read property 'getHomeChromosomeName' of undefined  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2019-04-29. Score: 2
  
  It looks as though the script is looking for a URL (fastaURL) so you could try specifying the file as file://directory/test.fasta
  
  By default though, javascript cannot read local files from disk for security reasons. Are you sure it is even possible to specify a local file in your script in this way? If yes, then the problem is likely that you need to specify the path correctly.
  
  > **Comments:**
  > **username_0**: Thanks for the comment.  I tried specifying the file as you suggested, but no luck.  Perhaps it is the JavaScript limitation.  I suppose I respect why that design decision is made, but for in internal use only purpose, it seems limiting.  
  > **username_2**: One way to get round it is to host the web page and the FASTA file together in your own local webserver directory.  OSX has a built in local webserver that you can switch on without too much difficulty - then open the page from your browser using http://localhost/test.html   You would then be able to refer to the FASTA file as test.fasta as your script does now (URL relative to the calling page).  
  > **username_0**: That did the trick.  Both files must be on a server and it does indeed work.  
  
  ---
  
  ### Answer by username_3 on 2019-10-30. Score: 1
  
  just stumbled on this. I'm the developer of igv.js. Please feel free to open issues and questions on our git forum, I don't often have time to browse other forums.
  
  Browsers will not allow loading of local files by file path in javascript, if they did it would be a gigantic security hole. This restriction includes "file://" urls. Local files can be loaded by user action (clicking a button), that is supported in igv.js but there is no button for it as igv.js is designed as a component to embed in pages, not an application by itself. For an example see igv.org/app (<https://github.com/igvteam/igv-webapp>), a minimal application wrapping igv.js. You'll find "local file" options for genomes and tracks there.
  
  
  ---
  
  