Answers.Body: <p>I like this question a lot. Firstly I don't know singularity, but I know Docker and it will be similar. <code>docker exec</code> is very similar.</p>
  <p>So for example the reasons are likely as follows:</p>
  <ul>
  <li><code>media</code> could be empty and hence no output.</li>
  <li>the Python script may not be in <code>/proc</code></li>
  <li>singularity is likely to be a file rather than a directory.</li>
  </ul>
  <p>One solution is,</p>
  <pre><code>singularity exec ~/CNV_kit/cnvkit_latest.sif /bin/bash -c &quot;ls -l /&quot;
  </code></pre>
  <p>i.e. ask it which are the directories. Another solution is..</p>
  <pre><code>singularity exec ~/CNV_kit/cnvkit_latest.sif /bin/bash -c &quot;find / -name 'cnvkit*'&quot;
  </code></pre>
  <p>This will locate <code>cnvkit.py</code>, note the use of ' and &quot; for this sort of command.</p>
  <p>Personally, I would dive into the container and issue the command of interest, manually. This way you get a feel for how it's constructed and don't need to keep issuing commands from outside the container. In Docker this is easy and it's impossible to keep a third party out of a container (even if the developer tries). In singularity it is likely similar.</p>
  <hr />
  <p><strong>From the notes</strong> I would simply access the singularity container directly.</p>
  <p>Accessing a singularity container is different from Docker (I looked it up) ...</p>
  <pre><code>singularity shell ~/CNV_kit/cnvkit_latest.sif 
  </code></pre>
  <p>Once inside you'll be able to look around, try out the <code>find</code> command, look in the <code>bin</code> etc... There will be no need to issue commands from outside the container to get it working.</p>
  <hr />
  <p>From further comments,</p>
  <p>A node on an HPC is a group of usually 8 to 32+ CPUs. What you have is a 'master' or 'head' node, where you log into and keep your data, and the stuff you do the work on is called 'nodes'. It has a more specific name, but it's not very cool, so we don't use it. The HPC will comprise a large number of nodes, e.g. 100+, but can be smaller particularly with the massive CPU machines around now. A node concept is a bit different on a NVidia machine if its part of a cluster.</p>
  <p>The issue is someone could have called a script 'node', which would be confusing. It's complicated, because someone could have their own research machine which is attached and maintained on. the HPC, but only they can access and called it e.g. 'Joes_node', of 'Jills_node'.</p>
  <p>Personally, I would sit down with your administrator and ask them to explain singularity and this the comments herein and this. They will know that at admin level (thats their job).</p>
  <p>From my point of view, if I'd access to a cluster using singularity I could figure it out. I use GCP now, it's geeky but cool, so my information is out of date on non-Cloud clusters.</p>
  <hr />
  <p><strong>RamRS comments</strong>
  What RamRS is saying and what I'm trying to assess whether you are within a singularity container. Again, I don't know the architecture.</p>
  <p><strong>Merging With Accepted Answer:</strong></p>
  <p>The main file in cnvkit is <code>cnvkit.py</code> in order to find that you need to look using <code>singularity exec</code>. The following command gives the path to the cnvkit.py file:</p>
  <pre class="lang-bash prettyprint-override"><code>singularity exec cnvkit_latest.sif /bin/bash -c &quot;cd /usr/local/bin/ &amp;&amp; ls&quot;
  </code></pre>
  <p>An example of how to use this path is below:</p>
  <pre><code># Directory containing sample files:
  directory=&quot;/path/to/bam/files/folder&quot;
  
  # Define path to singularity image:
  cnvkit_container=&quot;/path/to/cnvkit_latest.sif&quot;
  
  cnvkit_path=&quot;/usr/local/bin/cnvkit.py&quot;
  
  singularity exec &quot;<span class="math-container">$cnvkit_container" "$</span>cnvkit_path&quot; call &quot;<span class="math-container">$directory/sample.cns" -o "$</span>directory/sample.call.cns&quot;
  
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-05-26T19:15:57.233Z
Answers.Text: For some reason on my HPC it just says permission denied but it does not allow me to find the path?
Answers.UserDisplayName: Indira
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-05-26T19:43:48.353Z
Answers.Text: I'd recommend looking under `/bin/`. Also, is there a Dockerfile like config that defines an entry point? If so, it should be straightforward to find out where things lie.
Answers.UserDisplayName: Ram RS
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-05-26T20:53:53.500Z
Answers.Text: I can't access docker via my HPC. And under bin there is ```FileCheck-11         icuinfo     resolvectl
   GET          id     rev
   HEAD          infocmp     rgrep
   POST          infotocap     rm``` but not anything that I can tell is directly related to the cnv kit py files?
Answers.UserDisplayName: Indira
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-05-26T21:25:22.827Z
Answers.Text: @Indira Wait there's a misunderstanding singularity vs Docker. I would access the singularity container directly. The command to do so is below the ---- line in my post.
Answers.UserDisplayName: M__
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-05-26T21:29:46.910Z
Answers.Text: but wouldn't I need to use `singularity exec` to access the path to be able to use CNV kit?
Answers.UserDisplayName: Indira
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-05-26T21:31:23.863Z
Answers.Text: Use `singularity shell` to find and test the executable, then use `singularity exec` to use it.
Answers.UserDisplayName: Ram RS
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-05-26T21:31:59.410Z
Answers.Text: @Indira if you use the `shell` command it will give you access to the container - it operates just like an enclosed system (because it is). You will then be able to figure out how to run it via `exec`. If you try the `shell` command you will see after e.g. `pwd`.
Answers.UserDisplayName: M__
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-05-26T21:33:32.740Z
Answers.Text: @RamRS beat me to it and yes 100% agree.
Answers.UserDisplayName: M__
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-05-26T21:34:32.737Z
Answers.Text: @M__ I was unaware that `singularity shell` is a thing, thank you so much!
Answers.UserDisplayName: Ram RS
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-05-26T21:41:38.840Z
Answers.Text: I did `singularity shell cnvkit_latest.sif` and then `find /path/to/cnvkit_latest.sif -type f -name "*.py"` but it doesn't give any output?
Answers.UserDisplayName: Indira
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-05-26T21:43:37.043Z
Answers.Text: Run `find / -name "c*.py"`. You're within the singularity container's shell, so searching with the path to the container does not make sense.
Answers.UserDisplayName: Ram RS
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-05-26T21:56:00.880Z
Answers.Text: Even with `singularity shell cnvkit_latest.sif` when I run `find / -name "c*.py".` it doesn't work - it searches not just in the singularity but through all the nodes that other users use. I did get one path that seemed like what I would be looking for `'/etc/ssl/private'` and it said `Permission denied` so I tried `singularity exec cnvkit_latest.sif /bin/bash -c "cd /etc/ssl/private/ && ls"` and it still said `Permission denied`
Answers.UserDisplayName: Indira
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-05-26T22:09:48.700Z
Answers.Text: Are you sure you're running the command from within the singularity shell? Compare the output to `singularity exec file.sif /bin/bash -c "ls /"` run from your HPC shell and a simple `ls /` from within singularity shell. The output should be ***identical***
Answers.UserDisplayName: Ram RS
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-05-26T22:20:26.627Z
Answers.Text: I am sure I am running it in the shell
Answers.UserDisplayName: Indira
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-05-26T22:23:42.417Z
Answers.Text: @Indira what is the output of `pwd` after the `shell` command?
Answers.UserDisplayName: M__
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-05-29T13:32:08.743Z
Answers.Text: I told that the shell command with the find searches through other people nodes and pulls up their files with a similar python files such as under Amy_node and Barbara_node, but I only want it under my node.
Answers.UserDisplayName: Indira
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-05-29T16:39:07.180Z
Answers.Text: I see ... I know what you are doing via singularity  but I lack specific knowledge
Answers.UserDisplayName: M__
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-05-30T13:33:03.537Z
Answers.Text: By "node" do you mean compute node?
Answers.UserDisplayName: Ram RS
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-05-30T13:41:00.737Z
Answers.Text: Yes I am one an hpc so it does mean a computing node.
Answers.UserDisplayName: Indira
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-05-30T14:52:16.497Z
Answers.Text: Thank you know more than me about how to use this site.
Answers.UserDisplayName: Indira
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-05-30T14:57:14.643Z
Answers.Text: I'll convert the comments to chat or a wiki shortly. The chat site is here: https://chat.stackexchange.com/rooms/58858/bioinformatics if you call a user e.g. @M__ that will trigger a notification to that member.
Answers.UserDisplayName: M__
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-05-30T16:51:18.323Z
Answers.Text: @M__ The nomenclature is now head and worker nodes. Even GitHub has now renamed the principal code branch to main, so the nomenclature you're censoring is outdated.
Answers.UserDisplayName: Ram RS
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-06-04T23:01:49.460Z
Answers.Text: Is it possible to merge @M__ answer and my answer as it is on the same topic?
Answers.UserDisplayName: Indira
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-05-26T16:29:57.220Z
Answers.LastActivityDate: 2023-06-05T21:14:00.870Z
Answers.LastEditDate: 2023-06-05T21:14:00.870Z
Answers.UserDisplayName: M__
Answers.Body: <p>Thanks to OP for sharing that their image is from <a href="https://hub.docker.com/r/etal/cnvkit" rel="nofollow noreferrer">https://hub.docker.com/r/etal/cnvkit</a></p>
  <p>I downloaded this and it seems pretty simple.</p>
  <p>My tests:</p>
  <pre><code>singularity pull docker://etal/cnvkit:latest
  $ singularity shell ./cnvkit_latest.sif
  INFO:    Converting SIF file to temporary sandbox...
  bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
  Singularity&gt; ls /
  bin  boot  dev  environment  etc  home  lib  lib32  lib64  libx32  media  mnt  opt  proc  root  run  sbin  singularity  srv  sys  tmp  usr  var
  Singularity&gt; ls /singularity
  /singularity
  Singularity&gt; cnvkit.py
  usage: cnvkit.py [-h]
                   {batch,target,access,antitarget,autobin,coverage,reference,fix,segment,call,diagram,scatter,heatmap,breaks,genemetrics,gainloss,sex,gender,metrics,segmetrics,bintest,import-picard,import-seg,import-theta,import-rna,export,version}
                   ...
  
  CNVkit, a command-line toolkit for copy number analysis.
  
  positional arguments:
    {batch,target,access,antitarget,autobin,coverage,reference,fix,segment,call,diagram,scatter,heatmap,breaks,genemetrics,gainloss,sex,gender,metrics,segmetrics,bintest,import-picard,import-seg,import-theta,import-rna,export,version}
                          Sub-commands (use with -h for more info)
      batch               Run the complete CNVkit pipeline on one or more BAM files.
      target              Transform bait intervals into targets more suitable for CNVkit.
      access              List the locations of accessible sequence regions in a FASTA file.
      antitarget          Derive off-target (&quot;antitarget&quot;) bins from target regions.
      autobin             Quickly calculate reasonable bin sizes from BAM read counts.
      coverage            Calculate coverage in the given regions from BAM read depths.
      reference           Compile a coverage reference from the given files (normal samples).
      fix                 Combine target and antitarget coverages and correct for biases. Adjust raw coverage data according to the given reference, correct potential biases and re-center.
      segment             Infer copy number segments from the given coverage table.
      call                Call copy number variants from segmented log2 ratios.
      diagram             Draw copy number (log2 coverages, segments) on chromosomes as a diagram. If both the raw probes and segments are given, show them side-by-side on each chromosome (segments on the left side, probes on the right
                          side).
      scatter             Plot probe log2 coverages and segmentation calls together.
      heatmap             Plot copy number for multiple samples as a heatmap.
      breaks              List the targeted genes in which a copy number breakpoint occurs.
      genemetrics         Identify targeted genes with copy number gain or loss.
      sex                 Guess samples' sex from the relative coverage of chromosomes X and Y.
      metrics             Compute coverage deviations and other metrics for self-evaluation.
      segmetrics          Compute segment-level metrics from bin-level log2 ratios.
      bintest             Test for single-bin copy number alterations.
      import-picard       Convert Picard CalculateHsMetrics tabular output to CNVkit .cnn files. The input file is generated by the PER_TARGET_COVERAGE option in the CalculateHsMetrics script in Picard tools. If 'antitarget' is in the
                          input filename, the generated output filename will have the suffix '.antitargetcoverage.cnn', otherwise '.targetcoverage.cnn'.
      import-seg          Convert a SEG file to CNVkit .cns files.
      import-theta        Convert THetA output to a BED-like, CNVkit-like tabular format. Equivalently, use the THetA results file to convert CNVkit .cns segments to integer copy number calls.
      import-rna          Convert a cohort of per-gene log2 ratios to CNVkit .cnr format.
      export              Convert CNVkit output files to another format.
      version             Display this program's version.
  
  options:
    -h, --help            show this help message and exit
  
  See the online manual for details: https://cnvkit.readthedocs.io
  Singularity&gt; which cnvkit.py
  /usr/local/bin/cnvkit.py
  </code></pre>
  <p>As you can see, since <code>cnvkit.py</code> is in <code>/usr/local/bin/</code>, simply typing <code>cnvkit.py</code> within the shell works. Let's try an exec with no frills:</p>
  <pre><code>$ singularity exec cnvkit_latest.sif cnvkit.py
  INFO:    Converting SIF file to temporary sandbox...
  usage: cnvkit.py [-h]
                   {batch,target,access,antitarget,autobin,coverage,reference,fix,segment,call,diagram,scatter,heatmap,breaks,genemetrics,gainloss,sex,gender,metrics,segmetrics,bintest,import-picard,import-seg,import-theta,import-rna,export,version}
                   ...
  
  CNVkit, a command-line toolkit for copy number analysis.
  
  positional arguments:
    {batch,target,access,antitarget,autobin,coverage,reference,fix,segment,call,diagram,scatter,heatmap,breaks,genemetrics,gainloss,sex,gender,metrics,segmetrics,bintest,import-picard,import-seg,import-theta,import-rna,export,version}
                          Sub-commands (use with -h for more info)
      batch               Run the complete CNVkit pipeline on one or more BAM files.
      target              Transform bait intervals into targets more suitable for CNVkit.
      access              List the locations of accessible sequence regions in a FASTA file.
      antitarget          Derive off-target (&quot;antitarget&quot;) bins from target regions.
      autobin             Quickly calculate reasonable bin sizes from BAM read counts.
      coverage            Calculate coverage in the given regions from BAM read depths.
      reference           Compile a coverage reference from the given files (normal samples).
      fix                 Combine target and antitarget coverages and correct for biases. Adjust raw coverage data according to the given reference, correct potential biases and re-center.
      segment             Infer copy number segments from the given coverage table.
      call                Call copy number variants from segmented log2 ratios.
      diagram             Draw copy number (log2 coverages, segments) on chromosomes as a diagram. If both the raw probes and segments are given, show them side-by-side on each chromosome (segments on the left side, probes on the right
                          side).
      scatter             Plot probe log2 coverages and segmentation calls together.
      heatmap             Plot copy number for multiple samples as a heatmap.
      breaks              List the targeted genes in which a copy number breakpoint occurs.
      genemetrics         Identify targeted genes with copy number gain or loss.
      sex                 Guess samples' sex from the relative coverage of chromosomes X and Y.
      metrics             Compute coverage deviations and other metrics for self-evaluation.
      segmetrics          Compute segment-level metrics from bin-level log2 ratios.
      bintest             Test for single-bin copy number alterations.
      import-picard       Convert Picard CalculateHsMetrics tabular output to CNVkit .cnn files. The input file is generated by the PER_TARGET_COVERAGE option in the CalculateHsMetrics script in Picard tools. If 'antitarget' is in the
                          input filename, the generated output filename will have the suffix '.antitargetcoverage.cnn', otherwise '.targetcoverage.cnn'.
      import-seg          Convert a SEG file to CNVkit .cns files.
      import-theta        Convert THetA output to a BED-like, CNVkit-like tabular format. Equivalently, use the THetA results file to convert CNVkit .cns segments to integer copy number calls.
      import-rna          Convert a cohort of per-gene log2 ratios to CNVkit .cnr format.
      export              Convert CNVkit output files to another format.
      version             Display this program's version.
  
  options:
    -h, --help            show this help message and exit
  
  See the online manual for details: https://cnvkit.readthedocs.io
  INFO:    Cleaning up image...
  </code></pre>
  <p>The answer seems to be a lot easier than having to find <code>cnvkit.py</code>, as it is already in the PATH.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-06-01T16:20:11.550Z
Answers.Text: This did not work for me as it seems to work differently on the HPC I am on.
Answers.UserDisplayName: Indira
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-06-01T18:19:40.640Z
Answers.Text: That does not make much sense. There could be something unusual with your HPC. Perhaps you should contact your sysadmin.
Answers.UserDisplayName: Ram RS
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-06-02T13:37:05.207Z
Answers.Text: I have done so and I simply have to navigate around these issues using the path inside the singularity image.
Answers.UserDisplayName: Indira
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-05-30T16:36:53.477Z
Answers.LastActivityDate: 2023-05-30T16:36:53.477Z
Answers.UserDisplayName: Ram RS
Body: <p>I would like to try an use Singularity with CNV kit as the HPC I use seems to work better with Singularity:</p>
  <p><em><strong>Initial Attempt:</strong></em></p>
  <pre><code>singularity exec ~/CNV_kit/cnvkit_latest.sif /bin/bash -c &quot;ls /&quot;
  </code></pre>
  <ul>
  <li><em>Result</em>:</li>
  </ul>
  <pre><code>bin  boot  dev  environment  etc  home  lib  lib32  lib64  libx32  media  mnt  opt  proc  root  run  sbin  singularity  srv  sys  tmp  usr  var
  </code></pre>
  <p><em><strong>Attempt 1:</strong></em></p>
  <pre><code>singularity exec ~/CNV_kit/cnvkit_latest.sif /bin/bash -c &quot;cd /proc/ &amp;&amp; ls&quot;
  </code></pre>
  <p>This results in a folder with a series of numbers but not the cnvkit py files.</p>
  <p><em><strong>Attempt 2:</strong></em></p>
  <pre><code>singularity exec ~/CNV_kit/cnvkit_latest.sif /bin/bash -c &quot;cd /singularity/ &amp;&amp; ls&quot;
  </code></pre>
  <p>This results in <code>/bin/bash: line 1: cd: /singularity/: Not a directory</code></p>
  <p><em><strong>Attempt 3:</strong></em></p>
  <pre><code> singularity exec ~/CNV_kit/cnvkit_latest.sif /bin/bash -c &quot;cd /media/ &amp;&amp; ls&quot;
  </code></pre>
  <p>This results in nothing being printed to the screen. I tried this command three times to be sure.</p>
  <p>How can I find the Singularity path I would need to use with <code>singularity exec</code> to run from the Singularity image.</p>
  
Tags: <bash><singularity>
Title: Singularity And CNV Kit
ThreadText: # Singularity And CNV Kit
  
  (Asked by: username_0 on 2023-05-26)
  
  I would like to try an use Singularity with CNV kit as the HPC I use seems to work better with Singularity:
  
  ***Initial Attempt:***
  
  ```
  singularity exec ~/CNV_kit/cnvkit_latest.sif /bin/bash -c "ls /"
  
  ```
  
  * *Result*:
  
  ```
  bin  boot  dev  environment  etc  home  lib  lib32  lib64  libx32  media  mnt  opt  proc  root  run  sbin  singularity  srv  sys  tmp  usr  var
  
  ```
  
  ***Attempt 1:***
  
  ```
  singularity exec ~/CNV_kit/cnvkit_latest.sif /bin/bash -c "cd /proc/ && ls"
  
  ```
  
  This results in a folder with a series of numbers but not the cnvkit py files.
  
  ***Attempt 2:***
  
  ```
  singularity exec ~/CNV_kit/cnvkit_latest.sif /bin/bash -c "cd /singularity/ && ls"
  
  ```
  
  This results in `/bin/bash: line 1: cd: /singularity/: Not a directory`
  
  ***Attempt 3:***
  
  ```
   singularity exec ~/CNV_kit/cnvkit_latest.sif /bin/bash -c "cd /media/ && ls"
  
  ```
  
  This results in nothing being printed to the screen. I tried this command three times to be sure.
  
  How can I find the Singularity path I would need to use with `singularity exec` to run from the Singularity image.
  
  **Tags:** bash, singularity
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2023-05-26. Score: 2 | Accepted answer
  
  I like this question a lot. Firstly I don't know singularity, but I know Docker and it will be similar. `docker exec` is very similar.
  
  So for example the reasons are likely as follows:
  
  * `media` could be empty and hence no output.
  * the Python script may not be in `/proc`
  * singularity is likely to be a file rather than a directory.
  
  One solution is,
  
  ```
  singularity exec ~/CNV_kit/cnvkit_latest.sif /bin/bash -c "ls -l /"
  
  ```
  
  i.e. ask it which are the directories. Another solution is..
  
  ```
  singularity exec ~/CNV_kit/cnvkit_latest.sif /bin/bash -c "find / -name 'cnvkit*'"
  
  ```
  
  This will locate `cnvkit.py`, note the use of ' and " for this sort of command.
  
  Personally, I would dive into the container and issue the command of interest, manually. This way you get a feel for how it's constructed and don't need to keep issuing commands from outside the container. In Docker this is easy and it's impossible to keep a third party out of a container (even if the developer tries). In singularity it is likely similar.
  
  ---
  
  **From the notes** I would simply access the singularity container directly.
  
  Accessing a singularity container is different from Docker (I looked it up) ...
  
  ```
  singularity shell ~/CNV_kit/cnvkit_latest.sif 
  
  ```
  
  Once inside you'll be able to look around, try out the `find` command, look in the `bin` etc... There will be no need to issue commands from outside the container to get it working.
  
  ---
  
  From further comments,
  
  A node on an HPC is a group of usually 8 to 32+ CPUs. What you have is a 'master' or 'head' node, where you log into and keep your data, and the stuff you do the work on is called 'nodes'. It has a more specific name, but it's not very cool, so we don't use it. The HPC will comprise a large number of nodes, e.g. 100+, but can be smaller particularly with the massive CPU machines around now. A node concept is a bit different on a NVidia machine if its part of a cluster.
  
  The issue is someone could have called a script 'node', which would be confusing. It's complicated, because someone could have their own research machine which is attached and maintained on. the HPC, but only they can access and called it e.g. 'Joes\_node', of 'Jills\_node'.
  
  Personally, I would sit down with your administrator and ask them to explain singularity and this the comments herein and this. They will know that at admin level (thats their job).
  
  From my point of view, if I'd access to a cluster using singularity I could figure it out. I use GCP now, it's geeky but cool, so my information is out of date on non-Cloud clusters.
  
  ---
  
  **username_2 comments**
  What username_2 is saying and what I'm trying to assess whether you are within a singularity container. Again, I don't know the architecture.
  
  **Merging With Accepted Answer:**
  
  The main file in cnvkit is `cnvkit.py` in order to find that you need to look using `singularity exec`. The following command gives the path to the cnvkit.py file:
  
  ```bash
  singularity exec cnvkit_latest.sif /bin/bash -c "cd /usr/local/bin/ && ls"
  
  ```
  
  An example of how to use this path is below:
  
  ```
  # Directory containing sample files:
  directory="/path/to/bam/files/folder"
  
  # Define path to singularity image:
  cnvkit_container="/path/to/cnvkit_latest.sif"
  
  cnvkit_path="/usr/local/bin/cnvkit.py"
  
  singularity exec "$cnvkit_container" "$cnvkit_path" call "$directory/sample.cns" -o "$directory/sample.call.cns"
  
  ```
  
  > **Comments:**
  > **username_0**: For some reason on my HPC it just says permission denied but it does not allow me to find the path?  
  > **username_2**: I'd recommend looking under `/bin/`. Also, is there a Dockerfile like config that defines an entry point? If so, it should be straightforward to find out where things lie.  
  > **username_0**: I can't access docker via my HPC. And under bin there is ```FileCheck-11         icuinfo     resolvectl  GET          id     rev  HEAD          infocmp     rgrep  POST          infotocap     rm``` but not anything that I can tell is directly related to the cnv kit py files?  
  > **username_1**: @username_0 Wait there's a misunderstanding singularity vs Docker. I would access the singularity container directly. The command to do so is below the ---- line in my post.  
  > **username_0**: but wouldn't I need to use `singularity exec` to access the path to be able to use CNV kit?  
  > **username_2**: Use `singularity shell` to find and test the executable, then use `singularity exec` to use it.  
  > **username_1**: @username_0 if you use the `shell` command it will give you access to the container - it operates just like an enclosed system (because it is). You will then be able to figure out how to run it via `exec`. If you try the `shell` command you will see after e.g. `pwd`.  
  > **username_1**: @username_2 beat me to it and yes 100% agree.  
  > **username_2**: @username_1 I was unaware that `singularity shell` is a thing, thank you so much!  
  > **username_0**: I did `singularity shell cnvkit_latest.sif` and then `find /path/to/cnvkit_latest.sif -type f -name "*.py"` but it doesn't give any output?  
  > **username_2**: Run `find / -name "c*.py"`. You're within the singularity container's shell, so searching with the path to the container does not make sense.  
  > **username_0**: Even with `singularity shell cnvkit_latest.sif` when I run `find / -name "c*.py".` it doesn't work - it searches not just in the singularity but through all the nodes that other users use. I did get one path that seemed like what I would be looking for `'/etc/ssl/private'` and it said `Permission denied` so I tried `singularity exec cnvkit_latest.sif /bin/bash -c "cd /etc/ssl/private/ && ls"` and it still said `Permission denied`  
  > **username_2**: Are you sure you're running the command from within the singularity shell? Compare the output to `singularity exec file.sif /bin/bash -c "ls /"` run from your HPC shell and a simple `ls /` from within singularity shell. The output should be ***identical***  
  > **username_0**: I am sure I am running it in the shell  
  > **username_1**: @username_0 what is the output of `pwd` after the `shell` command?  
  > **username_0**: I told that the shell command with the find searches through other people nodes and pulls up their files with a similar python files such as under Amy_node and Barbara_node, but I only want it under my node.  
  > **username_1**: I see ... I know what you are doing via singularity  but I lack specific knowledge  
  > **username_2**: By "node" do you mean compute node?  
  > **username_0**: Yes I am one an hpc so it does mean a computing node.  
  > **username_0**: Thank you know more than me about how to use this site.  
  > **username_1**: I'll convert the comments to chat or a wiki shortly. The chat site is here: https://chat.stackexchange.com/rooms/58858/bioinformatics if you call a user e.g. @username_1 that will trigger a notification to that member.  
  > **username_2**: @username_1 The nomenclature is now head and worker nodes. Even GitHub has now renamed the principal code branch to main, so the nomenclature you're censoring is outdated.  
  > **username_0**: Is it possible to merge @username_1 answer and my answer as it is on the same topic?  
  
  ---
  
  ### Answer by username_2 on 2023-05-30. Score: 0
  
  Thanks to OP for sharing that their image is from <https://hub.docker.com/r/etal/cnvkit>
  
  I downloaded this and it seems pretty simple.
  
  My tests:
  
  ```
  singularity pull docker://etal/cnvkit:latest
  $ singularity shell ./cnvkit_latest.sif
  INFO:    Converting SIF file to temporary sandbox...
  bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
  Singularity> ls /
  bin  boot  dev  environment  etc  home  lib  lib32  lib64  libx32  media  mnt  opt  proc  root  run  sbin  singularity  srv  sys  tmp  usr  var
  Singularity> ls /singularity
  /singularity
  Singularity> cnvkit.py
  usage: cnvkit.py [-h]
                   {batch,target,access,antitarget,autobin,coverage,reference,fix,segment,call,diagram,scatter,heatmap,breaks,genemetrics,gainloss,sex,gender,metrics,segmetrics,bintest,import-picard,import-seg,import-theta,import-rna,export,version}
                   ...
  
  CNVkit, a command-line toolkit for copy number analysis.
  
  positional arguments:
    {batch,target,access,antitarget,autobin,coverage,reference,fix,segment,call,diagram,scatter,heatmap,breaks,genemetrics,gainloss,sex,gender,metrics,segmetrics,bintest,import-picard,import-seg,import-theta,import-rna,export,version}
                          Sub-commands (use with -h for more info)
      batch               Run the complete CNVkit pipeline on one or more BAM files.
      target              Transform bait intervals into targets more suitable for CNVkit.
      access              List the locations of accessible sequence regions in a FASTA file.
      antitarget          Derive off-target ("antitarget") bins from target regions.
      autobin             Quickly calculate reasonable bin sizes from BAM read counts.
      coverage            Calculate coverage in the given regions from BAM read depths.
      reference           Compile a coverage reference from the given files (normal samples).
      fix                 Combine target and antitarget coverages and correct for biases. Adjust raw coverage data according to the given reference, correct potential biases and re-center.
      segment             Infer copy number segments from the given coverage table.
      call                Call copy number variants from segmented log2 ratios.
      diagram             Draw copy number (log2 coverages, segments) on chromosomes as a diagram. If both the raw probes and segments are given, show them side-by-side on each chromosome (segments on the left side, probes on the right
                          side).
      scatter             Plot probe log2 coverages and segmentation calls together.
      heatmap             Plot copy number for multiple samples as a heatmap.
      breaks              List the targeted genes in which a copy number breakpoint occurs.
      genemetrics         Identify targeted genes with copy number gain or loss.
      sex                 Guess samples' sex from the relative coverage of chromosomes X and Y.
      metrics             Compute coverage deviations and other metrics for self-evaluation.
      segmetrics          Compute segment-level metrics from bin-level log2 ratios.
      bintest             Test for single-bin copy number alterations.
      import-picard       Convert Picard CalculateHsMetrics tabular output to CNVkit .cnn files. The input file is generated by the PER_TARGET_COVERAGE option in the CalculateHsMetrics script in Picard tools. If 'antitarget' is in the
                          input filename, the generated output filename will have the suffix '.antitargetcoverage.cnn', otherwise '.targetcoverage.cnn'.
      import-seg          Convert a SEG file to CNVkit .cns files.
      import-theta        Convert THetA output to a BED-like, CNVkit-like tabular format. Equivalently, use the THetA results file to convert CNVkit .cns segments to integer copy number calls.
      import-rna          Convert a cohort of per-gene log2 ratios to CNVkit .cnr format.
      export              Convert CNVkit output files to another format.
      version             Display this program's version.
  
  options:
    -h, --help            show this help message and exit
  
  See the online manual for details: https://cnvkit.readthedocs.io
  Singularity> which cnvkit.py
  /usr/local/bin/cnvkit.py
  
  ```
  
  As you can see, since `cnvkit.py` is in `/usr/local/bin/`, simply typing `cnvkit.py` within the shell works. Let's try an exec with no frills:
  
  ```
  $ singularity exec cnvkit_latest.sif cnvkit.py
  INFO:    Converting SIF file to temporary sandbox...
  usage: cnvkit.py [-h]
                   {batch,target,access,antitarget,autobin,coverage,reference,fix,segment,call,diagram,scatter,heatmap,breaks,genemetrics,gainloss,sex,gender,metrics,segmetrics,bintest,import-picard,import-seg,import-theta,import-rna,export,version}
                   ...
  
  CNVkit, a command-line toolkit for copy number analysis.
  
  positional arguments:
    {batch,target,access,antitarget,autobin,coverage,reference,fix,segment,call,diagram,scatter,heatmap,breaks,genemetrics,gainloss,sex,gender,metrics,segmetrics,bintest,import-picard,import-seg,import-theta,import-rna,export,version}
                          Sub-commands (use with -h for more info)
      batch               Run the complete CNVkit pipeline on one or more BAM files.
      target              Transform bait intervals into targets more suitable for CNVkit.
      access              List the locations of accessible sequence regions in a FASTA file.
      antitarget          Derive off-target ("antitarget") bins from target regions.
      autobin             Quickly calculate reasonable bin sizes from BAM read counts.
      coverage            Calculate coverage in the given regions from BAM read depths.
      reference           Compile a coverage reference from the given files (normal samples).
      fix                 Combine target and antitarget coverages and correct for biases. Adjust raw coverage data according to the given reference, correct potential biases and re-center.
      segment             Infer copy number segments from the given coverage table.
      call                Call copy number variants from segmented log2 ratios.
      diagram             Draw copy number (log2 coverages, segments) on chromosomes as a diagram. If both the raw probes and segments are given, show them side-by-side on each chromosome (segments on the left side, probes on the right
                          side).
      scatter             Plot probe log2 coverages and segmentation calls together.
      heatmap             Plot copy number for multiple samples as a heatmap.
      breaks              List the targeted genes in which a copy number breakpoint occurs.
      genemetrics         Identify targeted genes with copy number gain or loss.
      sex                 Guess samples' sex from the relative coverage of chromosomes X and Y.
      metrics             Compute coverage deviations and other metrics for self-evaluation.
      segmetrics          Compute segment-level metrics from bin-level log2 ratios.
      bintest             Test for single-bin copy number alterations.
      import-picard       Convert Picard CalculateHsMetrics tabular output to CNVkit .cnn files. The input file is generated by the PER_TARGET_COVERAGE option in the CalculateHsMetrics script in Picard tools. If 'antitarget' is in the
                          input filename, the generated output filename will have the suffix '.antitargetcoverage.cnn', otherwise '.targetcoverage.cnn'.
      import-seg          Convert a SEG file to CNVkit .cns files.
      import-theta        Convert THetA output to a BED-like, CNVkit-like tabular format. Equivalently, use the THetA results file to convert CNVkit .cns segments to integer copy number calls.
      import-rna          Convert a cohort of per-gene log2 ratios to CNVkit .cnr format.
      export              Convert CNVkit output files to another format.
      version             Display this program's version.
  
  options:
    -h, --help            show this help message and exit
  
  See the online manual for details: https://cnvkit.readthedocs.io
  INFO:    Cleaning up image...
  
  ```
  
  The answer seems to be a lot easier than having to find `cnvkit.py`, as it is already in the PATH.
  
  > **Comments:**
  > **username_0**: This did not work for me as it seems to work differently on the HPC I am on.  
  > **username_2**: That does not make much sense. There could be something unusual with your HPC. Perhaps you should contact your sysadmin.  
  > **username_0**: I have done so and I simply have to navigate around these issues using the path inside the singularity image.  
  
  ---
  
  