<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[How to...]]></title><description><![CDATA[<p>How to preview first 10 lines of a gzipped file:</p>
<pre><code class="language-java">gunzip -c ./filename.gz | head -n 10
</code></pre>
<p>How to view the first 10 lines of a bam file header:</p>
<pre><code class="language-java">samtools view -h /sequence.bam | head -n 10
</code></pre>
<p>How to view the total size of a folder (or file):</p>
<pre><code>du -sh /folder/path
</code></pre>
<p>How to list files with permissions and human readable file sizes:</p>
<pre><code>ls -halt
</code></pre>
<p>How to filter bash history for a keyword:</p>
<pre><code>history|grep keyword
</code></pre>
<p>How to erase everything in a file using vi/vim:</p>
<pre><code>:1,$d
</code></pre>
<p>How to get paste to work properly with Vim:</p>
<pre><code>:set paste
</code></pre>
<p>How to re-attach to a running docker containers and view logs in the console:</p>
<pre><code>cd /folder/containing/docker-compose.yml/
docker-compose logs -f -t
</code></pre>
<p>How to clear a NodeBB plugin:</p>
<pre><code>./nodebb reset -p nodebb-plugin-name
</code></pre>
<p>How to do an ldapsearch for a user:</p>
<pre><code>ldapsearch -x -H ldap://your.ldap.database.domain.com:389 -D 'cn=admin,dc=client_domain,dc=com' -b 'dc=client_domain,dc=com' -w adminpassord &quot;(cn=user_name_being_searched_for)&quot;
</code></pre>
<p>How to detach from screen:</p>
<pre><code>ctrl+a then ctrl+d
</code></pre>
<p>How to find tags from a remote git repository</p>
<pre><code>git ls-remote --tags https://path/to/repository.git
</code></pre>
<p>How to calculate disk usage of current directory, retrieve only top 5 and ignore permission errors:</p>
<pre><code>du -cBM --max-depth=1 ./ 2&gt;/dev/null | sort -n | tail -n 5
</code></pre>
<p>How to calculate disk usage of system:</p>
<pre><code>df -h
</code></pre>
<p>How to ssh tunnel through a jump server with an ssh key. In this case, key1.pem is required for access to the jump server. Access to the destination server does not require a key but can only be achieved through the jump server.</p>
<pre><code>ssh -i /path/to/your/key1.pem -o &quot;ProxyCommand ssh -W %h:%p -i /path/to/your/key1.pem username1@jump.server.com&quot; username2@destination.server.com
</code></pre>
<p>How to use rsync to transfer files FROM the current directory on a local server TO a folder on a remote server through a jump server. In this case, key1.pem is required for access to the jump server. Access to the remote server does not require a key but can only be achieved through the jump server. Sudo access on the remote server requires a password.</p>
<pre><code>rsync -avhR --delete --rsync-path=&quot;echo sudoPasswordOnRemoteServer  | sudo -Sv &amp;&amp; sudo rsync&quot; --partial-dir=./.rsync-partial -e &quot;ssh -i /path/to/your/key1.pem&quot; ./ \
username@remote.server.com:/destination_folder
</code></pre>
<p>How to use rsync to transfer files TO the current directory on a local server FROM multiple source folders on a remote server through a jump server. In this case, key1.pem is required for access to the jump server. Access to the remote server does not require a key but can only be achieved through the jump server. Sudo access on the remote server requires a password. A text file is also create that records files that cannot be accessed and excludes them from the rsync command.</p>
<pre><code>exclude_file=./exclude.txt
rm ./exclude.txt

ssh -i /path/to/your/key1.pem -o &quot;ProxyCommand ssh -W %h:%p -i /path/to/your/key1.pem username@remote.server.com&quot; username@remote.server.com 'echo sudoPasswordOnRemoteServer | sudo -S find \
/source_folder_1 \
! -readable' &gt;&gt;&quot;$exclude_file&quot;

ssh -i /path/to/your/key1.pem -o &quot;ProxyCommand ssh -W %h:%p -i /path/to/your/key1.pem username@remote.server.com&quot; username@remote.server.com 'echo sudoPasswordOnRemoteServer | sudo -S find \
/source_folder_2 \
! -readable' &gt;&gt;&quot;$exclude_file&quot;

rsync -avhR --delete --rsync-path=&quot;echo sudoPasswordOnRemoteServer | sudo -Sv &amp;&amp; sudo rsync&quot; --exclude-from=&quot;$exclude_file&quot; --partial-dir=./.rsync-partial -e &quot;ssh -i /path/to/your/key1.pem&quot; \
username@remote.server.com:/source_folder_1/ \
username@remote.server.com:/source_folder_2/ \
./
</code></pre>
<p>How to do a case-insensitve search in linux with the find command:</p>
<pre><code>find / -iname &quot;*stringYouAreLookingFor*&quot;
</code></pre>
<p>How to exclude a character in a perl regular expression. Eg. to find anything other than #:</p>
<pre><code>[^#]
</code></pre>
<p>How to specify the location of a perl library or module in the current directory. Place the folder containing the module in the same directory as the perl script (eg ./Algorithm/Loops.pm):</p>
<pre><code>use lib '.' ;
use Algorithm::Loops 'NestedLoops';
</code></pre>
<p>How to identify tandem repeats in Perl:</p>
<pre><code>my $dat = '01011010';
$dat =~ /(?=(.+)\1)(?!(??{ '.+?(..{' . length($^N) . ',})\1' }))/;
print &quot;$1\n&quot;;
</code></pre>
<p>How to do indents in markdown:</p>
<pre><code>&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; This text is indented.
</code></pre>
<p>How to stop markdown displaying links:</p>
<pre><code>htt&amp;#8203;ps://commons.wikimedia.org/w/index.php?curid=31927819
</code></pre>
<p>How to get the host address from inside a docker container:</p>
<pre><code>ip route show default | awk '/default/ {print $3}'
</code></pre>
<p>How to hide all posts in a category (including from recent feed and unread feed) using css in NodeBB. This requires knowledge of the category number (82 in the case below):</p>
<pre><code>li[data-cid =&quot;82&quot;] {
   display: none;
}
</code></pre>
<p>How to log in to non-running docker container:</p>
<pre><code>docker run  -it image_name bash
</code></pre>
<p>How to inject Javascript code into ejs code:</p>
<pre><code>&lt;% code %&gt;: Code is evaluated but not printed out
&lt;%= code %&gt;: Code is evaluated and printed out (escaped)
&lt;%- code %&gt;: Code is evaluated and printed out (not escaped)
</code></pre>
<p>How to export to path in Perl:</p>
<pre><code>$ENV{'PATH'} .= ':'.'/new/path';
</code></pre>
<p>How to convert all bam files in a folder to sam:</p>
<pre><code>for file in ./*.bam
do
    echo $file
    samtools  view -h $file &gt; ${file/.bam/.sam}
done
</code></pre>
<p>How to extract a fastq read by it's title from a gz file:</p>
<pre><code>gunzip -c 150901_I188_FCC7F64ANXX_L3_wHAMPI021865-80_1.fq.gz | grep -A 3 &quot;HISEQ:378:C7F64ANXX:3:2109:10652:6636&quot; &gt;./found.1.fq
</code></pre>
<p>How to recursively delete a non-empty folder in Windows shell at the command prompt:</p>
<pre><code>rd /S /Q &quot;C:\path\to\folder&quot;
</code></pre>
<p>How to find orphaned/abandoned uploads/files in NodeBB:<br />
<a href="https://community.nodebb.org/topic/13698/a-way-for-clean-orphaned-files-images/2" rel="nofollow">ACP-&gt;Manage-&gt;Uploads-&gt;Check for 'orphaned' status-&gt;delete</a></p>
<ul>
<li>NB. You have to go through all the files listed and find the ones that are labelled 'orphaned'</li>
</ul>
<p>How to prevent empty line being inserted between divs in html:</p>
<pre><code>&lt;div style=&quot;padding:0;margin:0;clear:none;&quot;&gt;&lt;/div&gt;
&lt;div style=&quot;padding:0;margin:0;clear:none;&quot;&gt;&lt;/div&gt;
</code></pre>
<p>How to check how much space docker container logs are using:</p>
<pre><code>du -chs /var/lib/docker/containers/*/*json.log
</code></pre>
<p>How to store the output of a system call into a variable in Perl:</p>
<pre><code>my $com='ls';
my $variable=qx($com 2&gt;&amp;1);
</code></pre>
<p>How to retrieve paths to all container docker volumes on the host:</p>
<pre><code>docker inspect --format '{{range $mnt := .Mounts}} {{json $mnt.Source}} {{end}}' containerID
</code></pre>
<p>How to retrieve paths to one container docker volume on the host:</p>
<pre><code>docker inspect --format '{{ range .Mounts }}{{ if eq .Destination &quot;/data&quot; }}{{ .Source }}{{ end }}{{ end }}' containerID
</code></pre>
<p>How to find out how much space docker container log files are using:</p>
<pre><code>docker ps -qa | xargs docker inspect --format='{{.LogPath}}' | xargs sudo ls -hl
</code></pre>
<p>How to strip quotes surrounding a string in bash:</p>
<pre><code>volumePath='&quot;blah&quot;';
volumePath=$(eval echo $volumePath);
echo $volumePath
</code></pre>
<p>How to use CSS to hide html tags with href that start with some text and end with some text:</p>
<pre><code>a[href^=&quot;start_text&quot;][href$=&quot;end_text&quot;] {
    display: none; 
}
</code></pre>
<p>How to identify currency/money amounts/dollars with a regular expression in javascript:</p>
<pre><code>^[0-9]+(\.[0-9]{1,2})?$
</code></pre>
<p>How to identify alphanumeric characters in a regular expression with javascript:</p>
<pre><code>  this.match(/^[A-Za-z0-9]+$/);
</code></pre>
<p>How to remove all unused docker containers and volumes and networks:</p>
<pre><code>sudo docker system prune -a
sudo docker network prune
</code></pre>
<p>How to convert text in a text box or textarea into uppercase in html:</p>
<pre><code>text-transform: uppercase;
</code></pre>
<p>How to get a textarea in html to resize to the entered contents:</p>
<pre><code>&lt;script&gt;
    $(document).on('input', 'textarea', function () {
        $(this).outerHeight(38).outerHeight(this.scrollHeight); // 38 or '1em' -min-height
    }); 
&lt;/script&gt;
</code></pre>
<p>How to convert phred64 to phred33 in Perl and vice versa:</p>
<pre><code>$newqual = join( &quot;&quot;, map { chr( ord($_) - 64 + 33 ) } ( split( //, $oldqual ) ) );
$newqual = join( &quot;&quot;, map { chr( ord($_) - 33 + 64 ) } ( split( //, $oldqual ) ) );
</code></pre>
<p>How to find your stripe client id:</p>
<pre><code>https://dashboard.stripe.com/settings/applications
</code></pre>
<p>How to create an asynchronous code block in Node.js:</p>
<pre><code>(async () =&gt; { ... })();
</code></pre>
<p>How to use await Promise.all to wait for an asynchronous array to finish in Node.js before proceeding:</p>
<pre><code>/*This shows how to delete a list of files stored in a grid file system.*/
 
arrayOfFileNames=[&quot;file1.jpg&quot;, &quot;file2.jpg&quot;, &quot;file3.jpg&quot;];
 

async function asyncArrayWait(arrayOfFileNames) {
    try {
        await Promise.all(
            arrayOfFileNames.map(async (fileName) =&gt; {
                console.log('file name  '+fileName);
                await gfsRemoveAsync(fileName);
            }),
        );

        function gfsRemoveAsync(param){
            return new Promise((resolve,reject) =&gt; {
                gfs.remove(param, function(err){
                    if (err) {
                        reject(err);
                    }
                    else{
                        resolve('done');
                    }
                });
            });
        }
        
        console.log('All files in the array have now been deleted');
    }
    catch (error) {
    console.log('There was an error:  '+error);         
    }
}
</code></pre>
<p>How to sequentially perform functions using await in Node.js:</p>
<pre><code>let ID = '_idaghendhghner38393';

asyncRemoveStuff(ID);

async function asyncRemoveStuff(ID) {
    /* this function performs the three contained functions sequentially */
    try {

        /* This function depends on receiving the ID value from the parent function and returns its results in the obj2 variable*/

        let obj2= await gfsFindAsync({&quot;metadata.ID&quot;:ID});
        function gfsFindAsync(param){
            return new Promise((resolve,reject) =&gt; {
                gfs.files.find(param).toArray(function (err, obj) {
                    if (err) {
                        reject(err);
                    }
                    else{
                        resolve(obj);
                    }
                });
            });
        }



        /* This function depends on receiving the obj2 value from above*/

        await gfsRemoveAsync(obj2);
        function gfsRemoveAsync(param){
            return new Promise((resolve,reject) =&gt; {
                gfs.remove(param, function(err){
                    if (err) {
                        reject(err);
                    }
                    else{
                        resolve('done');
                    }
                });
            });
        }


        /* This function depends on receiving the ID value from the parent function*/

        await mongooseRemove({ 'info.ID' :  ID });
        function mongooseRemove(param){
            return new Promise((resolve,reject) =&gt; {
                MongooseDB.remove(param, function(err) {          
                    if (err){
                        reject(err);  
                    else{
                        let msg='Removed from the database';
                        resolve(msg)                        
                    }
                });
            });
        }
    }
    catch (error) {
        console.log('There was an error:  '+error);        
    }
}

</code></pre>
<p>How to randomly generate a grid of pixels image with javascript and canvas and post it as a value in a form:</p>
<pre><code>&lt;html&gt;
	&lt;body&gt;
		&lt;canvas id=&quot;myCanvas&quot; width=&quot;100&quot; height=&quot;100&quot; style=&quot;border:1px solid #d3d3d3;&quot;&gt;Your browser does not support the HTML5 canvas tag.&lt;/canvas&gt;

		&lt;form action=&quot;/fund-setup&quot; method=&quot;post&quot; enctype=&quot;multipart/form-data&quot;&gt;
			&lt;input type=&quot;hidden&quot; id=&quot;randomIcon&quot; name=&quot;randomIcon&quot; value=&quot;&quot;&gt;
			&lt;button type=&quot;submit&quot; &gt;Submit&lt;/button&gt;
		&lt;/form&gt;

		&lt;script&gt;
		  var canvas = document.getElementById('myCanvas'),ctx = canvas.getContext('2d'), x, y = 0, dim = canvas.width; ctx.translate(0.5, 0.5);                        
		  for(; y &lt; dim; y=y+20) {                          
		      for(x = 0; x &lt; dim; x=x+20) {
		          ctx.fillStyle = getRandomColor();          
		          ctx.fillRect(x, y, 20, 20);               
		      }
		  }
		  function getRandomColor() {
		      var r = 255*Math.random()|0,
		          g = 255*Math.random()|0,
		          b = 255*Math.random()|0;
		      return 'rgb(' + r + ',' + g + ',' + b + ')';
		  }
		  var canvasString = canvas.toDataURL();  
		  var randomIcon = document.getElementById('randomIcon');
		  randomIcon.value = canvas.toDataURL(&quot;image/jpeg&quot;, 0.5);        
		&lt;/script&gt;

	&lt;/body&gt;
&lt;/html&gt;

</code></pre>
<p>How to convert a callback function into a promise and use it with async await. This code must be contained within an async code block:</p>
<pre><code>let ID = '_idaghendhghner38393';

let obj2= await gfsFilesAsync({&quot;metadata.ID&quot;:ID});

function gfsFilesAsync(param){
    return new Promise((resolve,reject) =&gt; {
        gfs.files.find(param).toArray(function (err, obj) {
            if (err) {
                reject(err);
            }
            else{
                resolve(obj);
            }
        });
    });
}
</code></pre>
<p>How to use promise.all in an asynchronous code block to wait until an array of async functions complete:</p>
<pre><code>/*this is embedded in an async block*/
await Promise.all(
    fileNamesToDelete.map(async (ifile) =&gt; {
        /*the await below is important*/
        await gfsRemoveAsync({filename: ifile, root: 'images'});
        function gfsRemoveAsync(param){
            return new Promise((resolve,reject) =&gt; {
                gfs.remove(param, function (err) {
                    if (err) {
                        reject(err);
                    }
                    else{
                        resolve('done');
                    }
                });
            });
        }
    })
);

</code></pre>
<p>How to validate price fields with a regex:</p>
<pre><code>/^(\d*([.,](?=\d{3}))?\d+)+((?!\2)[.,]\d\d)?$/
</code></pre>
<p>How to specify the location of modules in Perl and Raku:</p>
<pre><code>#for the current directory
use lib '.' ;
#for the directory 'lib' in the current directory
use lib  'lib';
</code></pre>
<p>How to use functions from an external script in Node.js:</p>
<pre><code>#in external.js:
module.exports = function() { 
    this.add = function(a,b) { return a+b };
    this.divide = function(a,b) { return a/b };
    //etc
}

#in main.js:
require('external.js')();
add(1,2);
</code></pre>
<p>How to center test in markdown:</p>
<pre><code>&lt;p style=&quot;text-align: center;&quot;&gt;Centered text&lt;/p&gt;
</code></pre>
<p>How to convert a number to x decimal places in javascript:</p>
<pre><code>var cents=78.9
cents=cents.toFixed(2); //78.90
cents=78.997
cents=cents.toFixed(2); //79.00
</code></pre>
<p>How to launch the game of life with perl golf (no limits);</p>
<pre><code>perl -e '$c=q(((x7a/(x13)X4Ax!18)1817@0)4);$,=$/;$/=AX3AAAx76;$b=pack(&quot;(A)*&quot;,map{rand 3&lt;1}0..1816)x6;{print unpack&quot;(a79)23a0&quot;,$b;select$v,$v,$v,0.1;$b=pack&quot;(A)*&quot;,unpack&quot;$c&quot;,pack&quot;((a*)17xx!18)*&quot;,unpack&quot;x1737(AA$/Ax$/AA$/@)2222&quot;,$b;$a++;redo}'
</code></pre>
<p>How to launch the game of life with perl golf (with limits);</p>
<pre><code>perl -e '$a=0;$c=q(((x7a/(x13)X4Ax!18)1817@0)4);$,=$/;$/=AX3AAAx76;$b=pack(&quot;(A)*&quot;,map{rand 3&lt;1}0..1816)x6;{print unpack&quot;(a79)23a0&quot;,$b;select$v,$v,$v,0.1;$b=pack&quot;(A)*&quot;,unpack&quot;$c&quot;,pack&quot;((a*)17xx!18)*&quot;,unpack&quot;x1737(AA$/Ax$/AA$/@)2222&quot;,$b;$a++;redo if $a &lt;50;}'
</code></pre>
<p>How to control the width of a text box and make sure it is in the center of the page using inline CSS and html:</p>
<pre><code>&lt;input type=&quot;text&quot; style=&quot;max-width: 350px; margin:auto;&quot;  id=&quot;inputName&quot; name=&quot;inputName&quot;&gt;
</code></pre>
<p>How to dump a database from a non-standard port with mongodb:</p>
<pre><code>mongodump --port 87017 -d databaseName -o ./dump/databaseName-20200503
</code></pre>
<p>How to migrate a nodebb mongodb to a new server:</p>
<ul>
<li>Backup the nodebb database on the old server:</li>
</ul>
<pre><code>mongodump -u nodebb -p [password] -d nodebb -o dump/nodebb-2018-03-30
</code></pre>
<ul>
<li>On the new server, restore the nodebb database from the backup:</li>
</ul>
<pre><code>mongorestore -u nodebb -p [password] -d nodebb dump/nodebb-2018-03-30/nodebb/
</code></pre>
<ul>
<li>NB. It seems you have to reinstall/upgrade NodeBB after this, otherwise there are strange errors with pages not loading properly unless you reload them etc.</li>
</ul>
<p>How to find IP addresses of users who have successfully logged in to an Ubuntu/Debian server:</p>
<pre><code>zgrep sshd /var/log/auth.log* -h |grep -F 'Accepted'
</code></pre>
<p>How to recreate a Dockerfile from a docker image:</p>
<pre><code>#NB. unfortunatlely if an ADD or COPY command was used you cannot work out what files were added/copied
docker history --no-trunc=true image1 &gt; image1-dockerfile
</code></pre>
<p>How to get the IP address of a Docker container:</p>
<pre><code>docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $INSTANCE_ID
</code></pre>
<p>How to get the IP address of a running Docker container that has a hyphen in it's name and save it in a variable:</p>
<pre><code>IP=$(docker inspect --format '{{$network := index .NetworkSettings.Networks &quot;container-name_default&quot;}}{{$network.IPAddress}}' $(docker ps -q))
echo $IP
</code></pre>
<p>How to find an element in an array within an object and only display the desired element in MongoDB (the $ is important!):</p>
<pre><code>db.things.find({&quot;stuff.arraystuff&quot;: {&quot;$elemMatch&quot;: {&quot;ID&quot;: '1b6c0f70dd',&quot;nr&quot;:'908484f1127c'}}}, {&quot;stuff.arraystuff.$&quot;: 1})
</code></pre>
<p>How to reset/re-activate cut and paste function to/from VirtualBox linux guest and Windows host:</p>
<pre><code>#in linux guest:
killall VBoxClient
VBoxClient-all
</code></pre>
<p>How to draw on top of a pdf:</p>
<pre><code>Tools-&gt;Comment-&gt;[select pencil-drawing tool-icon]
</code></pre>
<p>How to load an R data file (.RData) into a variable in R:</p>
<pre><code>var1 &lt;-  get(load(&quot;D:/path/to/file.RData&quot;))
</code></pre>
<p>How to encode dummy variables in R using the Caret package:</p>
<pre><code>dummy_variablez &lt;- dummyVars(&quot; ~ .&quot;, data = variablez)
</code></pre>
<p>How to manually encode a dummy variable in R:</p>
<pre><code>df$female &lt;- ifelse(df$sex == female', 1, 0)
</code></pre>
<p>How to convert a range of columns in R to numeric (from character):</p>
<pre><code>#without dplyr:
dataz[,2:6] &lt;- sapply(dataz[,2:6],as.numeric)

#using dplyr:
if (!require(dplyr)) install.packages(&quot;dplyr&quot;)
library(dplyr)
library(dplyr)
dataz[,2:6] %&gt;% mutate_if(is.character,as.numeric)
</code></pre>
<p>How to change the label of a checkbox with JQuery:</p>
<pre><code>&lt;label id=&quot;lblfilter-green&quot; class=&quot;btn btn-outline-secondary btn-sm&quot;&gt;&lt;input type=&quot;checkbox&quot; name=&quot;direction&quot; id=&quot;filter-green&quot; /&gt;&lt;span&gt;&amp;nbsp;descending&lt;/span&gt;&lt;/label&gt;
&lt;script&gt;
    $('label').click(function () {
        var checked = $('input', this).is(':checked');
        $('span', this).text(checked ? ' ascending' : ' descending');
    });
&lt;/script&gt;
</code></pre>
<p>How to log into a screen session from multiple computers:</p>
<pre><code>screen -x nameofsession
</code></pre>
<p>How to preview an image after selecting it in html:</p>
<pre><code>&lt;img id=&quot;blah&quot; width=&quot;auto&quot; height=&quot;100&quot; /&gt;
&lt;input  type=&quot;file&quot; name=&quot;myTopImage&quot; onchange=&quot;document.getElementById('blah').src = window.URL.createObjectURL(this.files[0])&quot; /&gt;

</code></pre>
<p>How to submit a form when you select an image in html:</p>
<pre><code>&lt;input  type=&quot;file&quot; name=&quot;myImage&quot; onchange=&quot;form.submit()&quot; /&gt;
</code></pre>
<p>How to install local R packages in RStudio:</p>
<pre><code>if (!require(ThePackage)) install.packages(&quot;/path/to/the/package.tar.gz&quot;,repos = NULL, type=&quot;source&quot;)
</code></pre>
<p>How to remove the &quot;Powered by&quot; footer in NodeBB:</p>
<pre><code>ACP &gt; Extend &gt; Widgets, look at Global Footer.
</code></pre>
<p>How to process all files of a specific type in a specific directory using bash:</p>
<pre><code>	dir=&quot;.&quot;
	file=&quot;*.list&quot;
        #the if statement below prevents any error message if the file type doesn't exist
        if ls ${dir}/$file &gt;/dev/null  2&gt;&amp;1; then
	        for file in `cd ${dir};ls -1 ${file}` ;do
	           echo $file
	        done  
        fi
</code></pre>
<p>How to add elements to a list using a for loop in R:</p>
<pre><code>listz &lt;-rep(0,8)
for (i in 1:length(listz)){
  print(i)
  listz&lsqb;&lsqb;i&rsqb;&rsqb; &lt;- i

}
print(listz)

</code></pre>
<p>How to sort an object by keys in javascript:</p>
<pre><code>        //object is obj
	Object.keys(obj).sort()
      	.forEach(function(v, i) {
        	console.log(v, obj[v]);
       	});
</code></pre>
<p>How to calculate a floating point percentage (with eight digits) in bash from variables with bc and assign it's value to a variable in bash:</p>
<pre><code>PCT=`echo &quot;scale=8; ($NO / $TOTNO)*100&quot; | bc`
</code></pre>
<p>How to read all lines in a file including the last line without a newline character in bash:</p>
<pre><code>input=file.txt
while read line || [ -n &quot;$line&quot; ]
do
   echo $line
done &lt; $input
</code></pre>
<p>How to match fq, fastq,fq.gz,fastq.gz files with a regex in bash:</p>
<pre><code>fileFormat=&quot;$1&quot;

if &lsqb;&lsqb; $fileFormat =~ [Ff]([Aa][Ss][Tt])?[Qq](\.&lsqb;&lsqb;:alnum:&rsqb;&rsqb;+)?$ &rsqb;&rsqb;; then
    echo &quot;its a FASTQ file&quot;
else
    echo &quot;its not a FASTQ file&quot;
fi
</code></pre>
<p>How to calculate the length of multi-line fasta records in multi-fasta files using bash / awk:</p>
<pre><code>awk '/^&gt;/{if (l!=&quot;&quot;) print l; print; l=0; next}{l+=length($0)}END{print l}' ./sequence.fasta
</code></pre>
<p>How to get the nextflow_dir path of the previous container in Nextflow and delete a file in it:</p>
<pre><code>#in the previous container set the file in an output command:
output:
     set file(&quot;${pair_id}_raw_snps_${round}.vcf&quot;) into raw_snps_ch

#in the next container set a val with an input command:
input:
     val(raw_snps) from raw_snps_ch

#In the script section, the $raw_snps variable will have the full path of the file in the nextflow_dir folder. You can then delete it:
script:
'''     
rm $raw_snps
'''
</code></pre>
<p>How to count the number of folders in a path in bash (i.e the number of levels in a directory structure) and store it in a variable:</p>
<pre><code>varz=`echo &quot;/directory/structure/&quot; | tr &quot; /&quot; &quot;- &quot; | wc -w`
</code></pre>
<p>How to untar a tar.gz file and omit the preceding directory structure:</p>
<pre><code>#first count the number of levels in the preceding directory structure to be omitted
varz=`echo &quot;/preceding/directory/structure/to be omitted/&quot; | tr &quot; /&quot; &quot;- &quot; | wc -w`
#in this case we are extracting it into a directory that is the same as the preceding directory to be omitted
#in addition we are using the k option so that extracting does not overwrite existing files/folders
tar --strip-components $varz -C /preceding/directory/structure/to be omitted/ -zxvkf /tarfile/tobeextracted.tar.gz

</code></pre>
<p>How to sort all columns in a pandas dataframe and reset the index in Python:</p>
<pre><code>   df.sort_values(by=df.columns.to_list(), axis=0, ascending=True, inplace=True, kind='quicksort', na_position='last')
   df=df.reset_index(drop=True)
</code></pre>
<p>How to transpose a 2D array in Python:</p>
<pre><code>2d=[
['A', 'B', 'C', 'D'],
['E', 'F', 'G', 'H'],
['I', 'J', 'K', 'L']
]

2dStar=list(zip(*2d))
print(2dStar)

</code></pre>
<p>How to create multiple columns at once in a dataframe with Python and Pandas using series:</p>
<pre><code>'''
Starting DF:
   A  B
0  6  1
1  8  4
Desired DF:
   A  B  C   D
0  6  1  16  56
1  8  4  18  58
'''
def myfunc1(row):
    C = row['A'] + 10
    D = row['A'] + 50
    return pd.Series([C, D])

df&lsqb;&lsqb;'C', 'D'&rsqb;&rsqb; = df.apply(myfunc1 ,axis=1)
</code></pre>
<p>How to apply a function over multiple columns in a Python Pandas dataframe to create a new column:</p>
<pre><code>import pandas as pd

df = pd.DataFrame({'ID':['1', '2', '3'], 'col_1': [0, 2, 3], 'col_2':[1, 4, 5]})
mylist = ['a', 'b', 'c', 'd', 'e', 'f']

def get_sublist(sta,end):
    return mylist[sta:end+1]

df['col_3'] = df.apply(lambda x: get_sublist(x['col_1'], x['col_2']), axis=1)

'''
Output:
  ID  col_1  col_2      col_3
0  1      0      1     [a, b]
1  2      2      4  [c, d, e]
2  3      3      5  [d, e, f]
'''
</code></pre>
<p>How to do matrix multiplication with a for loop or the numpy dot function (faster) in Python:</p>
<pre><code>   import numpy as np

    np.random.seed(seed)
    A = np.random.rand(n,n)
    B = np.random.rand(n,n)
    C = np.zeros((n,n))

    #With for loop:

    for i in range(n):
        for j in range(n):
            for k in range(n):
                C[i,j] += A[i,k]*B[k,j]

    #With dot function:

    C += A.dot(B)
                

</code></pre>
<p>How to initialise values in a dictionary in Python with defaultdict:</p>
<pre><code>from collections import defaultdict

D2 = defaultdict(int) 

#note below you don't first have to initialise the value to 0
D2['new-key'] += 1

print(D2)
</code></pre>
<p>How to iterate a list to get the index and value using the enumerate function in Python:</p>
<pre><code>for indexz,valuez in enumerate(listz):
    print(indexz,valuez)
</code></pre>
<p>How to split a string up into individual characters in Python:</p>
<pre><code>#the list function does this if given a string
stringz='atcgcgta'
listz=list(stringz)

</code></pre>
<p>How to cut a string at a range of positions provided as a list in Python:</p>
<pre><code>def get_slices(s, l):
    l = [0] + l + [len(s)]
    cut =[s[x:y] for x,y in zip(l, l[1:])]
    return cut

s='GCATAGTAATGTATTAATGGC'
l=[7, 15]
sliced=get_slices(s,l)
</code></pre>
<p>How to return the indexes of values in a list that pass a condition in Python:</p>
<pre><code>lz=[6, 9, 10, 6, 12]
newList = [ i for i,t in enumerate(lz) if t  &gt;= 9]
</code></pre>
<p>How to check if an element occurs in a list in Python:</p>
<pre><code>ex='slot'
listz=['luck', 'slot', 'just', 'opened', 'kitchen']
if ex in listz:
    print (&quot;found in list &quot;,ex)
if ex not in listz:
    print (ex,&quot; is not in the list &quot;)
</code></pre>
<p>How to retrieve key:value pairs from a dictionary that has keys common with another dictionary in Python:</p>
<pre><code>d1={'a':1,'c':1}
d2={'a':1,'b':1,'c':1}
common_dict = {x:d1[x] for x in d1 if x in d2} 
</code></pre>
<p>How to retrieve keys common to two dictionaries in Python 3:</p>
<pre><code>x={'a':1,'c':1}
y={'a':1,'b':1,'c':1}
for key in x:
    if key in y:
        print (key, x[key])
</code></pre>
<p>How to sort a dictionary in descending order by it's values and retrieve the first k pairs in Python:</p>
<pre><code>sorted_dictz=sorted(dictz.items(), key=lambda x: x[1], reverse=True)[:k]

</code></pre>
<p>How to get a list of indices of x elements with the highest values from a list in Python:</p>
<pre><code>x=5
listz=[1,6,3,9,6,7,6,8,3,5]
top_5_element_indexes = sorted(range(len(listz)), key = lambda sub: listz[sub])[-x:]
</code></pre>
<p>How to sum all the values in a 'value column' of a pandas dataframe according to strings in a 'key column' and then use those summed total values to create a new column that contains the value/total_value fraction for each occurence of the key in the original 'key column' :</p>
<pre><code>tot_value=df.groupby('key')['value'].sum()
df['fraction']=df.apply(lambda x: x['value']/tot_value[x['key'&rsqb;&rsqb;, axis=1)
</code></pre>
<p>How to compare two Pandas dataframes and retrieve the differences:</p>
<pre><code>#you can also have sort=False
pd.concat([df1, df2],sort=True).drop_duplicates(keep=False)
</code></pre>
<p>How to retrieve the first n elements of a set:</p>
<pre><code>for n,elem in enumerate(set_name):
    if n == 5:
        break
    print (elem)
</code></pre>
<p>How to simultaneously iterate through multiple lists of the same length in Python:</p>
<pre><code>    for r,c,v in zip(list1,list2,list3):
        print(&quot;r:&quot;,r)
        print(&quot;c:&quot;,c)
        print(&quot;v:&quot;,v)

</code></pre>
<p>How to sort and find unique elements in a list in Python (2 methods):</p>
<pre><code>    method1=sorted(set(listz))
    method2=sorted([*{*listz}])
</code></pre>
<p>How to do element-wise multiplication of two lists to create a new list in Python:</p>
<pre><code>newlist=[i * j for i, j in zip(list1, list2)]
</code></pre>
<p>How to merge two Pandas dataframes using columns with different names in Python:<br />
<img src="https://shanelynnwebsite-mid9n9g1q9y8tt.netdna-ssl.com/wp-content/uploads/2017/03/pandas-merge-join-different-variable-names-copy-e1488722312527.jpg" alt="alt text" class="img-responsive img-markdown" /></p>
<pre><code>df3=pd.merge(df1,df2&lsqb;&lsqb;'Code','Desc'&rsqb;&rsqb;,left_on='ID',right_on='Code',how='inner')
</code></pre>
<p>How to generate a random matrix of defined shape with floating point numbers between a minimum and maximum value  in Python with numpy:</p>
<pre><code>import numpy as np
m,n=(3,4)
min,max=-2.5,3.4
rand_matrix=np.random.uniform(min,max,(m*n)).reshape(m,n)
</code></pre>
<p>How to concatenate Python pandas dataframes with different column names and remove indexes:</p>
<pre><code>import numpy as np
#this trick uses numpy to remove the column names and indexes
df = pd.DataFrame( np.concatenate( (df1.values, df2.values), axis=0 ) )
#add column names in as a final step
df.columns = [ 'a', 'x', 'y' ]

</code></pre>
<p>How to retrieve multiple columns of a pandas dataframe by their name using regex:</p>
<pre><code>dfSub=df.filter(regex = 'City|Country|Region')
</code></pre>
<p>How to convert dates to timestamps (down to sub millisecond resolution) in a Python Pandas dataframe:</p>
<pre><code>df['Timestamp']=pd.to_datetime(df['Date'],errors='coerce')
df['Timestamp'] = df['Timestamp'].dt.strftime('%Y-%m-%d %H:%M:%S:%f')
</code></pre>
<p>How to concatenate multiple pandas dataframe columns in python:</p>
<pre><code>newdf =pd.concat([df['col1'], df['col2'],df2['col1'],df2['col2'&rsqb;&rsqb;, axis=1, ignore_index=True)
</code></pre>
<p>How to filter Python pandas dataframe by multiple conditions:</p>
<pre><code>is_1 = (df[&quot;Col1&quot;] == &quot;hello&quot;)
is_2 = (df[&quot;Col2&quot;] == &quot;is_it_me&quot;)
df_fil=df[is_1 &amp; is_2]
</code></pre>
<p>How to do left, right, inner and outer joins in Python with pandas dataframes:<br />
<img src="https://www.datasciencemadesimple.com/wp-content/uploads/2017/06/merge-in-R-2.jpg" alt="alt text" class="img-responsive img-markdown" /><br />
<img src="https://shanelynnwebsite-mid9n9g1q9y8tt.netdna-ssl.com/wp-content/uploads/2017/02/pd-merge_intro_image-e1488724380571.png" alt="alt text" class="img-responsive img-markdown" /></p>
<pre><code>#outer merge:
result = pd.merge(user_usage,
                 user_device&lsqb;&lsqb;'use_id', 'platform', 'device'&rsqb;&rsqb;,
                 on='use_id')
#left merge:
result = pd.merge(user_usage,
                 user_device&lsqb;&lsqb;'use_id', 'platform', 'device'&rsqb;&rsqb;,
                 on='use_id', 
                 how='left')
</code></pre>
<p>How to rename a column in a Python pandas dataframe:</p>
<pre><code>data.rename(columns={'gdp':'log(gdp)'}, inplace=True)
</code></pre>
<p>How to remove / drop multiple columns in a Python pandas dataframe:</p>
<pre><code>result.drop(['Name1','Name2'], axis=1, inplace=True)

#OR:
del df_states[&quot;Name1&quot;]
del df_states[&quot;Name2&quot;]
</code></pre>
<p>How to copy a Python pandas dataframe:</p>
<pre><code>df2=df.copy(deep=True)
</code></pre>
<p>How to extract only column 1 and 2 from a Python pandas dataframe and group by values in column 1 and then sum the aggregated column 2 values into a column named 'count' and then sort them in descending order:</p>
<pre><code>    sum_sorted_grouped_df = df&lsqb;&lsqb;'Col1','Col2'&rsqb;&rsqb;.groupby(['Col1'])['Col2'] \
                         .sum() \
                         .reset_index(name='count') \
                         .sort_values(['count'], ascending=False)
</code></pre>
<p>How to sort a Python pandas dataframe by values in two separate columns (the first ascending and the second descending):</p>
<pre><code>df.sort_values(['b', 'c'], ascending=[True, False], inplace=True)
</code></pre>
<p>How to change the dtype of a Python pandas dataframe column:</p>
<pre><code>df['Colz']=df['Colz'].astype('float64')
</code></pre>
<p>How to create a dictionary from two columns in a Python pandas dataframe:</p>
<pre><code>dictz=dict(zip(df['col1'],df['col2']))
</code></pre>
<p>How to create an empty pandas dataframe with column names in Python:</p>
<pre><code>column_names = [&quot;a&quot;, &quot;b&quot;, &quot;c&quot;]
df = pd.DataFrame(columns = column_names)
</code></pre>
<p>How to create a dictionary from an anonymous list in Python:</p>
<pre><code>a=dict(&lsqb;&lsqb;'w',1],['y',2&rsqb;&rsqb;)
print(a)
#{'w': 1, 'y': 2}
</code></pre>
<p>How to generate consecutive pairs from a list in Python:</p>
<pre><code>l = [1, 7, 3, 5]
for first, second in zip(l, l[1:]):
    print (first, second)

#1 7
#7 3
#3 5
</code></pre>
<p>How to generate pairs from two columns in a Python pandas dataframe and assign them as values using keys in another column:</p>
<pre><code>#generate pairs from two columns:
 zipz=zip(df['col2'],df['col3'])
#create dictionary with keys in another column
 dictz=dict( zip( df['col1'],zipz))
#output:
#{0: (999, 556), 1: (153, 995), 2: (679, 075)}

</code></pre>
<p>How to generate a COO matrix of m by n dimensions in Python with Scipy:</p>
<pre><code>R = [0, 0, 1, 1, 2, 2]
C = [1, 2, 0, 1, 0, 1]
V = [5, 2, 1, 1, 6, 1]
import scipy.sparse as sp
coo_matrix((V, (R, C)), shape=(n, m))
</code></pre>
<p>How to do COO and CSR matrix multiplication with Python Scipy:</p>
<pre><code>import numpy as np
import scipy.sparse as sp

R = [0, 0, 1, 1, 2, 2]
C = [1, 2, 0, 1, 0, 1]
V = [5, 2, 1, 1, 6, 1]
P=  [0,    2,    4,   6]

x = [1, 2, 3]

x = np.ones(num_verts)

#COO
COO = sp.coo_matrix((V, (R, C)))
COO.dot(x)

#CSR
CSR = A_coo_sp.tocsr() # or...    sp.csr_matrix((V,C,P))
CSR.dot(x)
</code></pre>
<p>How to write a function and apply it to a Python numpy matrix using vectorize:</p>
<pre><code>    Y = np.array(&lsqb;&lsqb;5, 2, 0],
                  [2, 4, 7&rsqb;&rsqb;)
    print(Y)
    #&lsqb;&lsqb;5 2 0]
    # [2 4 7&rsqb;&rsqb;
    def myfunc(a):
        #Return 1 if a&gt;0, otherwise return 0
        if a &gt; 0:
            return 1
        else:
            return 0
    vfunc = np.vectorize(myfunc)
    
    A=vfunc(Y)
    print(A)

    #&lsqb;&lsqb;1 1 0]
    # [1 1 1&rsqb;&rsqb; 


</code></pre>
<p>How to remove duplicated rows in a pandas dataframe in python:</p>
<pre><code>df.drop_duplicates(subset = None, inplace=True)
</code></pre>
<p>How get the index positions of elements in a numpy array that satisfy a filter condition using the 'where' function in Python and use them to retrieve their corresponding values:</p>
<pre><code>x = np.array([-4, 4, 5])
from numpy import where
k = where(x &gt; 0)[0]
#k=[1 2]
y=x[k]
#y=[4,5]

</code></pre>
<p>How to create an empty array in numpy using the empty() function in Python:</p>
<pre><code>#The values in the array are whatever is located in that memory address at the time.
#This is quicker than creating an array of zeros
from numpy import empty, arange
kx = empty(10, dtype=int)
print(kx)
</code></pre>
<p>How to use a list of index positions to reorder values in a Python numpy array:</p>
<pre><code>indexes=[4,3,2,1,0]
values=[10,9,8,7,6]
new=np.array([0] * len(values))
new[indexes]=values
print (new)
#[ 6  7  8  9 10]
</code></pre>
<p>How to get a list of index positions (array3) of elements in an array (array 1) that match elements in another array (array2) using numpy and Python:</p>
<pre><code>import numpy as np
array1=np.array([0,3,5,6,9,1,2,4,7,8])
#empty, dtype=int creates a list of length n. It has values equal to whatever was at that memory address at the time)
#as an alternative to empty() you could use:
#array3=np.array([0] * len(array1))
#however it is slower
array3 = empty(len(array1), dtype=int)
array2=np.array([0,1,2,3,4,5,6,7,8,9])
#The line below is where the magic happens. TBH I'm not so sure why it works, however it is not the same as array3=array1[array2]
array3[array1] = array2
print(array3)
#[0 5 6 1 7 2 3 8 9 4]


</code></pre>
<p>How to count the occurences of a string in a column of a Python pandas dataframe:</p>
<pre><code>counts = df['TITLE'].value_counts()
</code></pre>
<p>How to randomly pick a sample of fixed size from a numpy array in Python (without replacement):</p>
<pre><code>import numpy as np
population=np.array([0,1,2,3,4,5,6,7,8,9])
samplez = choice(population, size=5, replace=False)
</code></pre>
<p>How to reverse an array in Python using a subscript with two colons followed by minus 1:</p>
<pre><code>#b is the reverse of a
b=a[::-1]
</code></pre>
<p>How to get a list of indexes of an array in the order they would be in if the array values were sorted:</p>
<pre><code>x = np.array([3, 1, 2])
np.argsort(x)
#[1, 2, 0]
</code></pre>
<p>How to concatenate strings in two separate columns of a pandas dataframe in Python:</p>
<pre><code>df['concat']=df['col1']+'_'+df['col2']
</code></pre>
<p>How to calculate the mean of numpy arrays while ignoring any nan values in Python:</p>
<pre><code>arrayz= np.array(&lsqb;&lsqb;np.nan,  21.85, np.nan], [  6.95, np.nan, -31.55&rsqb;&rsqb;)
meanz=np.nanmean(arrayz)
</code></pre>
<p>How to create a comment block in a bash script:</p>
<pre><code>: &lt;&lt;'END'
comments go here
END

</code></pre>
<p>How to clear the contents of a text file in Python:</p>
<pre><code>open('output.txt', 'w').close()
</code></pre>
<p>How to remove a file extension and store it in a variable  in bash:</p>
<pre><code>filename='file.txt'
base=${filename%.*}
echo $base
#file
</code></pre>
<p>How to convert a Nextflow array into a bash array within a NextFlow shell script block:</p>
<pre><code>#reads='[1.fastq.gz, 2.fastq.gz]'
#remove square brackets
nfarray=\$(echo &quot;${reads//[][,!]}&quot;)
#split at commas
arr=(`echo \$nfarray | cut -d &quot;,&quot;  --output-delimiter=&quot; &quot; -f 1-`)
#print out first element
echo &quot;\${arr[0]}&quot;


#######################
#NB. When I retested the above code I seemed to get an error. Upon further testing it seemed that you can directly use nextflow arrays thus:

for filename in ${reads}; do
	filename=\$(echo &quot;\${filename//[][,!]}&quot;)
	echo \$(basename \${filename})
done

</code></pre>
<p>How to filter vcf files with bcftools:</p>
<pre><code>#http://samtools.github.io/bcftools/bcftools.html#expressions
bcftools filter --regions-file $pathToBed/BEDFILE.bed $inputVCF | bcftools filter -e &quot;QUAL &lt; 10 || F_MISSING &gt; 0.01 || MAF &gt; 0.98&quot; | bcftools view -m2 -M2 -v snps --output-type z --output-file $outputDIR/$name._filtered.vcf.gz | bcftools index -t --output-file $outputDIR/$name._filtered.vcf.gz.tbi
</code></pre>
<p>How to use eval in Perl to execute text as code:</p>
<pre><code>$name='yes';
$reg='s/yes/no/g';
my $code='$name'.' =~ '.$reg.';';
eval($code);
print &quot;$name\n&quot;;
#no

</code></pre>
<p>How to use bash to find the longest common substring between two strings:</p>
<pre><code>				word1=$b1
				word2=$b2
				if [ ${#word1} -lt ${#word2} ]
				then
					word1=$b2
					word2=$b1
				fi
				comsub=''
				for ((i=${#word2}; i&gt;0; i--)); do
					for ((j=0; j&lt;=${#word2}-i; j++)); do
						if &lsqb;&lsqb; $word1 =~ ${word2:j:i} &rsqb;&rsqb;
						then
							echo ${word2:j:i}
							comsub=${word2:j:i}
							break 2
						fi
					done
				
				done
</code></pre>
<p>How to only move a file if it exists in bash:</p>
<pre><code>[ ! -f a.txt ] || mv a.txt b.txt
</code></pre>
<p>How to use eval to process regular expressions supplied as text strings in Perl:</p>
<pre><code>my $string='cat';
my $reg='s/a/un/';
my $code='$string'.' =~ '.$reg.';';
eval($code);
</code></pre>
<p>How to use grep to find a regex in a directory of gzipped files in linux:</p>
<pre><code>find /path/to/dire -name \*.gz -print0 | xargs -0 zgrep -n -E 'GCGT|N|Y|y|W|w|K|k|V|v|U|u'
</code></pre>
<p>How to use bash with paste and shuf to randomly shuffle paired fastq files:</p>
<pre><code>paste &lt;(zcat test.2.fq.gz) &lt;(zcat test.2.fq.gz) | paste - - - - | shuf | awk -F'\t' '{OFS=&quot;\n&quot;; print $1,$3,$5,$7 &gt; &quot;random.1.fq&quot;; print $2,$4,$6,$8 &gt; &quot;random.2.fq&quot;}'
</code></pre>
<p>How to extract specific lines from an archived gzipped gz file (and print out the line numbers):</p>
<pre><code>gunzip -c file.gz | awk -v from=10 -v to=20 'NR&gt;=from { print NR,$0; if (NR&gt;=to) exit 1}'
</code></pre>
<p>How to strip leading and trailing quotes from a string in Python:</p>
<pre><code>    if (string[0] == string[-1]) and string.startswith((&quot;'&quot;, '&quot;')):
        string=string[1:-1]
</code></pre>
<p>How to get the path, file name, base name and extension in bash:</p>
<pre><code>full_name=&quot;/foo/fuzz.bar&quot;
file_name=$(basename ${full_name})
base_name=${file_name%%.*}
extension=&quot;${filename##*.}&quot;
path=${full_name##*/}
</code></pre>
<p>How to process samples with multiple paired reads per sample using NextFlow:</p>
<p><a href="https://stackoverflow.com/questions/69702077/nextflow-how-to-process-multiple-samples" rel="nofollow">https://stackoverflow.com/questions/69702077/nextflow-how-to-process-multiple-samples</a></p>
<p>How to change a NextFlow/Groovy channel variable in a script and then put it back in a channel (file method):</p>
<pre><code>	process changer {
		cpus 1
		memory '1 GB'
		time '1m'
	   input:
			val(variable1) from ch1
			
		output:
			file(*) into ch2
		script:

			&quot;&quot;&quot;
			echo &quot;variable1 is: &quot;$variable1
			variable2=&quot;hello: $variable1&quot;
			touch \$variable2
			&quot;&quot;&quot;
	}

	process reintroducer {
		cpus 1
		memory '1 GB'
		time '1m'
		
	        input:
			//How to get the base filename without extensions in Nextflow with simpleName
			val(variable3) from ch2.map { file -&gt; file.simpleName }		
		output:
			val (variable3) into ch3
		script:
			&quot;&quot;&quot;
			echo &quot;variable3 is:&quot;$variable3
			&quot;&quot;&quot;
	}
</code></pre>
<p>How to apply a regex to a channel variable in NextFlow:</p>
<pre><code>
	process getSimpleName {
		//scratch true
		cpus 4
		memory { 0.GB +(24.GB * task.attempt) }	
		time { 14.hour + (8.hour * task.attempt) }
		errorStrategy { (task.exitStatus in 1..272 &amp;&amp; task.attempt &lt;= maxRetries)  ? 'retry' : 'terminate' }
		maxRetries 5	


		input:
			val(modified_names) from original_names_ch.map ({ varz -&gt; varz.replaceFirst(/\*\//,&quot;&quot;).replaceAll(&quot;\\.txt&quot;, &quot;&quot;) })


		output:			
			val(modified_names) into modified_names_ch


		script:
			&quot;&quot;&quot;
                        echo &quot;stripped proceeding paths and txt file extension to create &quot;$modified_names
			&quot;&quot;&quot;
	}
</code></pre>
<p>How to write a regex to identify all word characters (including _) in a variable in bash:</p>
<pre><code>string='abcd123'
regex='([_[:alnum:&rsqb;&rsqb;)'
				
if &lsqb;&lsqb; &quot;$string&quot; =~ $regex &rsqb;&rsqb;; then
    echo &quot;word characters found&quot;
fi					
</code></pre>
<p>How to test for the existence of unzipped or gzipped fasta files using a Perl one-liner:</p>
<pre><code>		flag=`perl -e 'BEGIN {$t=shift};my $fz=0;  if($t =~ /\.(fa|fasta|fa\.gz|fasta\.gz)$/){$fz=1};print &quot;$fz&quot;' ${file} `
			
		echo &quot;flag is: &quot;$flag
</code></pre>
<p>How to alphanumerically sort files that end with a number and store the results in a bash array using a Perl one-liner:</p>
<pre><code>#NB print0 appends null to the end. Consequently .$ must be present in the statement map {/(\d+).$/; [$_, $1];}
array3=(&quot;`find ${input} -type d  -mindepth 2  -print0 | perl -e '$/=&quot;\0&quot;; my @files=&lt;&gt;; my @sorted_array = map { $_-&gt;[0] } sort { $a-&gt;[1] &lt;=&gt; $b-&gt;[1]} map {/(\d+).$/; [$_, $1];} @files; print &quot;@sorted_array&quot;;'`&quot;)
</code></pre>
<p>How to get file attributes such as basename and filesize in NextFlow:<br />
<a href="https://www.nextflow.io/docs/latest/script.html#check-file-attributes" rel="nofollow">https://www.nextflow.io/docs/latest/script.html#check-file-attributes</a></p>
<p>How to collect all of the files produced by a NextFlow process and analyse each of them individually in separate processes:</p>
<pre><code>	process createFiles{
		cache false
		cpus 2
		memory '4 GB'
		time '4h'

		input:
			val(refz) from ref_ch2
			set val(pair_id), val(input_bam) from bam_for_intervals.mix(bam_for_intervals2).mix(bam_for_intervals3)	

		output:
		
			path (&quot;./intervals/*.list&quot;) into intz_ch
			val (input_bam) into bam_for_variant_calling
			
		publishDir &quot;${params.intervals}&quot;, mode:'move'
		
		script:
			scriptdir=params.scripts
			intervaldir=params.intervals

			&quot;&quot;&quot;
			filename=$input_bam
			filename=\$(echo &quot;\${filename//[][,!]}&quot;)		
			b1=\$(basename \$filename)
			input_bamz=${params.bam}/\${b1}
			
			dir=$params.ref
			filed=&quot;*.fa&quot;
			for file in `cd \${dir};ls -1 \${filed}` ;do
			   rf=$params.ref/\$file
			done			
			base=\${rf%.*}
			refdict=&quot;\${base}.dict&quot;	
			refname=\$(basename \$file)
			perl $scriptdir/fastaq2bed/fastaq2bed.plx  -i \$rf -o \$rf   || true
			java -jar \$PICARD_JAR BedToIntervalList \
				  I=\${rf}.bed \
				  O=\${refname}.interval_list \
				  SD=\${refdict}	
			perl $scriptdir/perl_mutect2/perl_mutect2.plx  -q \${rf} -i \${input_bamz} -s \${refname}.interval_list -x 'intervals'  -k ${params.max_interval_bp} -o ./   || true	  
			#dir=&quot;./intervals&quot;
			#filed=&quot;*.list&quot;
			#for file in `cd \${dir};ls -1 \${filed}` ;do
			   #mv \${dir}/\${file} &quot;${params.intervals}/&quot;
			#done 
				  
			&quot;&quot;&quot;
	}

process indexer {
	//NB. pgen_ch2 does not increment if cache is not set to false and is therefore essential
	//cache false
	//scratch true

	cpus 1
	memory '2 GB'
	time '1h'

    input:
		each (input_interval) from intz_ch.collect()
    output:	
		file (&quot;*.list&quot;) into pgen_ch3
    script:
	
    &quot;&quot;&quot;
		
		echo &quot;input_interval is ${input_interval}&quot;
		file_name=\$(basename ${input_interval})
		echo &quot;file_name is \${file_name}&quot;
		touch \${file_name}
    &quot;&quot;&quot;
}

process haplotypeCaller {
	scratch true
	cpus 4
	memory { 0.GB +(24.GB * task.attempt) }	
    time { 14.hour + (8.hour * task.attempt) }
    errorStrategy { (task.exitStatus in 1..272 &amp;&amp; task.attempt &lt;= maxRetries)  ? 'retry' : 'terminate' }
    maxRetries 5	

    input:
		set val(refz), val(bam_name), val(input_interval) from ref_ch3.combine(bam_for_variant_calling.combine(pgen_ch3))

    script:
		round=1
		&quot;&quot;&quot;
		
		echo &quot;input_interval is &quot;${input_interval}
		echo &quot;bam_name is &quot;${bam_name}
		ref_name=\$(basename ${refz})
		ref_base=\${ref_name%%.*}
		ref=\${ref_base}		
		
		file_name=\$(basename ${bam_name})
		base_name=\${file_name%%.*}
		pair_id=\${base_name}
		
		echo &quot;pair_id is &quot; \${pair_id}
		inz=&quot;${input_interval}&quot;
		interval_base_name=\${inz%%.*}
		interval_num=&quot;\$interval_base_name&quot;
		regex='([0-9]+).list'
		&lsqb;&lsqb; \$interval_num =~ \$regex &rsqb;&rsqb;
		echo \${BASH_REMATCH[1]}
		
		
		if [ &quot;$params.doJointCallingBQSR&quot; == &quot;true&quot; ] || [ &quot;$params.doJointCalling&quot; == &quot;true&quot; ]; then
			echo &quot;Doing joint calling&quot;
			gatk HaplotypeCaller \
			-R \$ref \
			-I ${params.bam}/$bam_name \
			-L ${params.intervals}/\$interval_base_name \
			--emit-ref-confidence GVCF \
			-O ${params.vcf}/\${pair_id}_raw_variants_${round}_\${BASH_REMATCH[1]}.g.vcf
		else	
			echo &quot;Not doing joint calling&quot;
			gatk HaplotypeCaller \
			-R \$ref \
			-I ${params.bam}/$bam_name \
			-L ${params.intervals}/\$interval_base_name \
			-O ${params.vcf}/\${pair_id}_raw_variants_${round}_\${BASH_REMATCH[1]}.vcf 
		fi
		&quot;&quot;&quot;
}
</code></pre>
<p>How to calculate md5 hash for a file in windows:</p>
<pre><code>certutil -hashfile file.txt MD5
</code></pre>
<p>How to calculate the md5 checksum for all files of a certain type in a folder using the Windows command line cmd.exe:</p>
<pre><code>#set the target folder, file type and output folder and paste the code below into the cmd shell.
#md5 checksums are written to \output_folder\md5.txt for each file and then sorted and an md5 checksum is created from the sorted text file
#The final results are in \output_folder\md5_final.txt
set &quot;target_folder=E:\test&quot;
set &quot;file_type=*.txt&quot;
set &quot;output_folder=E:&quot;
type NUL &gt; %output_folder%\md5.txt
for /R %target_folder% %f in (%file_type%) do @certutil -hashfile &quot;%f&quot; MD5  | findstr /V &quot;:&quot; &gt;&gt;%output_folder%\md5.txt
sort /M 10240 %output_folder%\md5.txt &gt; %output_folder%\md5_sorted.txt &amp; certutil -hashfile %output_folder%\md5_sorted.txt MD5 &gt; %output_folder%\md5_final.txt

</code></pre>
<p>How to search for a file and retrieve it's path in linux:</p>
<pre><code>find / -name 'libperl.so'  -exec readlink -f {} \;
</code></pre>
<p>How to print @INC with a perl one-liner:</p>
<pre><code>perl -e 'print &quot;@INC&quot;'
</code></pre>
<p>How to check for a matching file extension in bash:</p>
<pre><code>echo &quot;file name is read1.gz&quot;
if [ &quot;${read1##*.}&quot; = &quot;gz&quot; ]; then
    echo &quot;this is a gz file&quot;
fi
</code></pre>
<p>How to check if a specific file type / file extension exists in a directory in bash:</p>
<pre><code>dir=&quot;/path/to/dir&quot;
file=&quot;*.txt&quot;
if ls ${dir}/$file &gt;/dev/null  2&gt;&amp;1; then
   echo $file&quot; exists&quot;
fi
</code></pre>
<p>How to set the contents of a channel into two separate channels in Nextflow:</p>
<pre><code>Channel.fromPath(&quot;${params.path}/*.*cf&quot;).into({channel_1;channel2})

</code></pre>
<p>How to fix the error</p>
<p>[0m/.singularity.d/actions/exec: exec: line 9: /bin/bash: not found</p>
<p>with NextFlow and singularity containers built on alpine linux:</p>
<ul>
<li>Install bash when building the container</li>
</ul>
<pre><code>RUN apk add bash
</code></pre>
<p>How to make a NextFlow file channel send an empty file with a specific filename (&quot;empty_file&quot;) if the channel is empty:</p>
<pre><code>Channel.fromPath( &quot;/home/*.{txt,pdf}&quot; ).ifEmpty(file(&quot;empty_file&quot;)).set { new_ch }
</code></pre>
<p>How to remove the file extension from a filename generated by a path channel in NextFlow:</p>
<pre><code>val(ext) from ch.map({path -&gt; path.getFileName().normalize().toString().split(/\./)[0]})

#if you get the error &quot;Unknown method invocation `getName` on ArrayList type&quot;. Try the following:

val(ext) from ch.map({path -&gt; path[-1].getFileName().normalize().toString().split(/\./)[0]})

</code></pre>
<p>How to remove the preceding file path and get the base name from a filename generated by a path channel in NextFlow:</p>
<pre><code>val(basename) from ch.map({path -&gt; path.getFileName().normalize().toString().split(/\//)[-1]})

</code></pre>
<p>How to separate each element of an array in a file channel into individual channels in Nextflow. (This example also converts file paths to base names):</p>
<pre><code>#flatten may not always be required
each (val) from ch.map ({ file -&gt; file.simpleName }).flatten()

</code></pre>
<p>How to modify just one element of an array in a channel in NextFlow:</p>
<pre><code>#for the output channel of the previous process:
set val(val1), val(val2), file (&quot;*.txt&quot;) into output_ch


#for the input channel of the next process (this modifies the third element to get the file name of a file). Note how square brackets must be put around the output if you don't want the input flattened:

set val(valz1), val(valz2), val(filez) from output_ch.map ({ val1, val2, file -&gt; [pair_id, round, file.getName()] })
</code></pre>
<p>How to copy files from a docker container using a wildcard:</p>
<pre><code>#the secret is to use a . instead of *
docker cp container_id:/container_folder/. ./host_folder/
</code></pre>
<p>How to do non-integer maths in bash with bc and get an answer with a leading 0 in front of the decimal point and 6 decimal places and save it into a bash variable:</p>
<pre><code>rd1=&quot;scale=6; ${P}/${tot_reads}&quot;
rd2=`printf '%.6f' &quot;$(echo $rd1 | bc)&quot;`
</code></pre>
<p>How to increment a counter in Bash:</p>
<pre><code>COUNT=$((COUNT+1))
</code></pre>
<p>How to create an array in Bash by splitting a comma delimited string and then increment each value in the string by accessing each array element by it's index:</p>
<pre><code>UM='1,2,3,4,5,6'
UPM=($(echo $UM | tr &quot;,&quot; &quot;\n&quot;))

AM=''
for i in ${!UPM[*]}; do 
	echo ${UPM[$i]}
	ADDZ=`echo ${UPM[$i]}+1 | bc`
	AM=${AM}','${ADDZ}
done
	
UMF=`echo $AM | sed 's/^,//'`
</code></pre>
<p>How to delete all text in Vi text editor:</p>
<pre><code>:1,$d.
</code></pre>
<p>How to enter insert mode in Vi editor:</p>
<pre><code>press 'i'
</code></pre>
<p>How to exit insert mode in Vi editor:</p>
<pre><code>press 'esc'
</code></pre>
<p>How to save and exit in Vi editor:</p>
<pre><code>:wq! and enter
</code></pre>
<p>How to exit without saving in Vi editor:</p>
<pre><code>:q! and enter
</code></pre>
<p>How to pipe to and from bcftools using STDIN and STDOUT (standard input and standard output):</p>
<pre><code>#Ou is critical for STDOUT and - is critical for STDIN
bcftools norm -d none ./infile.vcf.gz -Ou | bcftools sort - –T ./temp -Oz -o ./outfile.vcf.gz
</code></pre>
<p>How to use brace expansion in bash to use ls to list all files that match multiple different patterns:</p>
<pre><code>pattern1='*.zip'
pattern2='*.gz'
dir='/bin'
filez=`echo {${pattern1},${pattern2}}`
#you could also use: filez=`echo {*.zip,*.gz}`
echo &quot;filez is: &quot;$filez
for file in `cd ${dir};ls ${filez} 2&gt;/dev/null` ;do
	echo \$file
done
				
</code></pre>
<p>How to replace non-printable characters in Perl (2 methods):</p>
<pre><code>#Method 1:
$v =~ s/\P{IsPrint}//g;
#Method 2:
$v =~ tr[\0-\x08\x0B\x0C\x0E-\x1F\x7F][\x{2400}-\x{2408}\x{240B}\x{240C}\x{240E}-\x{241F}\x{2421}];
</code></pre>
<p>How to use an IF statement in a Nextflow process to choose between two different input channels using a ternary operator:</p>
<pre><code>#uses ch1 if params.use_ch1 is true
val(A) from (params.use_ch1 == &quot;true&quot; ? ch1 : ch2)
</code></pre>
<p>How to convert a file containing channel generated by a NextFlow process to a value containing channel:</p>
<pre><code>
process generate{
	input:
		val (in) from in_ch
	output:
		file(&quot;*.{txt,doc}&quot;) into chz
	script:
		&quot;&quot;&quot;
		echo &quot;$in&quot;
		touch a.txt
		touch b.doc
		&quot;&quot;&quot;
}
//The channel ch1 now contains the filename surrounded by []
ch1=chz.collect ({ it.getName() })

process analyse{
	input:
		//flatten is required to remove the surrounding [] (and to launch one process per file name)
		val (valz) from ch1.flatten()
	script:
		&quot;&quot;&quot;
		echo &quot;$valz&quot;
		&quot;&quot;&quot;
}
</code></pre>
<p>How to do division in bash and give an answer as a whole number rounded up and store it in a variable:</p>
<pre><code>mem=24
cpuz=9
memz=`echo &quot;scale=0; (($mem + 0.5)/ $cpuz)&quot; | bc`
</code></pre>
<p>How to combine multiple Nextflow channels together into one channel:</p>
<pre><code>input:
	val(mixed) from ch1.collect().mix(ch2.collect()).mix(ch3.collect()).mix(ch4.collect()).collect()
</code></pre>
<p>How to mount another filesystem to a container (eg. Singularity) in a Nextflow process:</p>
<pre><code>process foo{
	containerOptions{
		//the folder specified in params.inFolder is mounted to /home in the container
		//NB perhaps be careful to not to mount such a large folder
		&quot;-B ${absolutePath('params.inFolder')}:/home&quot;
	}
	input:
		val (in) from in_ch
	output:
		file(&quot;*.txt&quot;) into out_ch

	```
	touch file.txt

	```

}
</code></pre>
<p>How to store a value from a script into a nextflow channel (this hasn't been tested):</p>
<pre><code>process myProcess {

   input:
      val (in) from inChannel

    output:
       shell '''
       echo &quot;Hello world!&quot;
       echo &quot;This is a multiline command.&quot;
       ''' into outChannel
}
</code></pre>
<p>How to re-enable the bi-directional clipboard in virtualbox with a xubuntu guest:</p>
<pre><code>systemctl restart vboxadd-service
#alternatively try:
sudo VBoxClient --clipboard
</code></pre>
<p>How to remove tabs between double quotes in a tab-separated file using a regular expression in Perl:</p>
<pre><code>#This assumes you cannot have escaped quotes inside your quotes. And that your fields themselves do not contain quotes.
$line = join &quot;&quot;, map {my $_ = $_; /^&quot;/ &amp;&amp; s/\t+//g; $_} $line =~ /&quot;[^&quot;]*&quot;|[^&quot;]*/g;
</code></pre>
]]></description><link>https://links.sharezomics.com/topic/56/how-to</link><generator>RSS for Node</generator><lastBuildDate>Fri, 15 May 2026 07:31:46 GMT</lastBuildDate><atom:link href="https://links.sharezomics.com/topic/56.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 08 Feb 2019 23:50:02 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to How to... on Fri, 18 Aug 2023 12:16:21 GMT]]></title><description><![CDATA[<p>How to preview first 10 lines of a gzipped file:</p>
<pre><code class="language-java">gunzip -c ./filename.gz | head -n 10
</code></pre>
<p>How to view the first 10 lines of a bam file header:</p>
<pre><code class="language-java">samtools view -h /sequence.bam | head -n 10
</code></pre>
<p>How to view the total size of a folder (or file):</p>
<pre><code>du -sh /folder/path
</code></pre>
<p>How to list files with permissions and human readable file sizes:</p>
<pre><code>ls -halt
</code></pre>
<p>How to filter bash history for a keyword:</p>
<pre><code>history|grep keyword
</code></pre>
<p>How to erase everything in a file using vi/vim:</p>
<pre><code>:1,$d
</code></pre>
<p>How to get paste to work properly with Vim:</p>
<pre><code>:set paste
</code></pre>
<p>How to re-attach to a running docker containers and view logs in the console:</p>
<pre><code>cd /folder/containing/docker-compose.yml/
docker-compose logs -f -t
</code></pre>
<p>How to clear a NodeBB plugin:</p>
<pre><code>./nodebb reset -p nodebb-plugin-name
</code></pre>
<p>How to do an ldapsearch for a user:</p>
<pre><code>ldapsearch -x -H ldap://your.ldap.database.domain.com:389 -D 'cn=admin,dc=client_domain,dc=com' -b 'dc=client_domain,dc=com' -w adminpassord &quot;(cn=user_name_being_searched_for)&quot;
</code></pre>
<p>How to detach from screen:</p>
<pre><code>ctrl+a then ctrl+d
</code></pre>
<p>How to find tags from a remote git repository</p>
<pre><code>git ls-remote --tags https://path/to/repository.git
</code></pre>
<p>How to calculate disk usage of current directory, retrieve only top 5 and ignore permission errors:</p>
<pre><code>du -cBM --max-depth=1 ./ 2&gt;/dev/null | sort -n | tail -n 5
</code></pre>
<p>How to calculate disk usage of system:</p>
<pre><code>df -h
</code></pre>
<p>How to ssh tunnel through a jump server with an ssh key. In this case, key1.pem is required for access to the jump server. Access to the destination server does not require a key but can only be achieved through the jump server.</p>
<pre><code>ssh -i /path/to/your/key1.pem -o &quot;ProxyCommand ssh -W %h:%p -i /path/to/your/key1.pem username1@jump.server.com&quot; username2@destination.server.com
</code></pre>
<p>How to use rsync to transfer files FROM the current directory on a local server TO a folder on a remote server through a jump server. In this case, key1.pem is required for access to the jump server. Access to the remote server does not require a key but can only be achieved through the jump server. Sudo access on the remote server requires a password.</p>
<pre><code>rsync -avhR --delete --rsync-path=&quot;echo sudoPasswordOnRemoteServer  | sudo -Sv &amp;&amp; sudo rsync&quot; --partial-dir=./.rsync-partial -e &quot;ssh -i /path/to/your/key1.pem&quot; ./ \
username@remote.server.com:/destination_folder
</code></pre>
<p>How to use rsync to transfer files TO the current directory on a local server FROM multiple source folders on a remote server through a jump server. In this case, key1.pem is required for access to the jump server. Access to the remote server does not require a key but can only be achieved through the jump server. Sudo access on the remote server requires a password. A text file is also create that records files that cannot be accessed and excludes them from the rsync command.</p>
<pre><code>exclude_file=./exclude.txt
rm ./exclude.txt

ssh -i /path/to/your/key1.pem -o &quot;ProxyCommand ssh -W %h:%p -i /path/to/your/key1.pem username@remote.server.com&quot; username@remote.server.com 'echo sudoPasswordOnRemoteServer | sudo -S find \
/source_folder_1 \
! -readable' &gt;&gt;&quot;$exclude_file&quot;

ssh -i /path/to/your/key1.pem -o &quot;ProxyCommand ssh -W %h:%p -i /path/to/your/key1.pem username@remote.server.com&quot; username@remote.server.com 'echo sudoPasswordOnRemoteServer | sudo -S find \
/source_folder_2 \
! -readable' &gt;&gt;&quot;$exclude_file&quot;

rsync -avhR --delete --rsync-path=&quot;echo sudoPasswordOnRemoteServer | sudo -Sv &amp;&amp; sudo rsync&quot; --exclude-from=&quot;$exclude_file&quot; --partial-dir=./.rsync-partial -e &quot;ssh -i /path/to/your/key1.pem&quot; \
username@remote.server.com:/source_folder_1/ \
username@remote.server.com:/source_folder_2/ \
./
</code></pre>
<p>How to do a case-insensitve search in linux with the find command:</p>
<pre><code>find / -iname &quot;*stringYouAreLookingFor*&quot;
</code></pre>
<p>How to exclude a character in a perl regular expression. Eg. to find anything other than #:</p>
<pre><code>[^#]
</code></pre>
<p>How to specify the location of a perl library or module in the current directory. Place the folder containing the module in the same directory as the perl script (eg ./Algorithm/Loops.pm):</p>
<pre><code>use lib '.' ;
use Algorithm::Loops 'NestedLoops';
</code></pre>
<p>How to identify tandem repeats in Perl:</p>
<pre><code>my $dat = '01011010';
$dat =~ /(?=(.+)\1)(?!(??{ '.+?(..{' . length($^N) . ',})\1' }))/;
print &quot;$1\n&quot;;
</code></pre>
<p>How to do indents in markdown:</p>
<pre><code>&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; This text is indented.
</code></pre>
<p>How to stop markdown displaying links:</p>
<pre><code>htt&amp;#8203;ps://commons.wikimedia.org/w/index.php?curid=31927819
</code></pre>
<p>How to get the host address from inside a docker container:</p>
<pre><code>ip route show default | awk '/default/ {print $3}'
</code></pre>
<p>How to hide all posts in a category (including from recent feed and unread feed) using css in NodeBB. This requires knowledge of the category number (82 in the case below):</p>
<pre><code>li[data-cid =&quot;82&quot;] {
   display: none;
}
</code></pre>
<p>How to log in to non-running docker container:</p>
<pre><code>docker run  -it image_name bash
</code></pre>
<p>How to inject Javascript code into ejs code:</p>
<pre><code>&lt;% code %&gt;: Code is evaluated but not printed out
&lt;%= code %&gt;: Code is evaluated and printed out (escaped)
&lt;%- code %&gt;: Code is evaluated and printed out (not escaped)
</code></pre>
<p>How to export to path in Perl:</p>
<pre><code>$ENV{'PATH'} .= ':'.'/new/path';
</code></pre>
<p>How to convert all bam files in a folder to sam:</p>
<pre><code>for file in ./*.bam
do
    echo $file
    samtools  view -h $file &gt; ${file/.bam/.sam}
done
</code></pre>
<p>How to extract a fastq read by it's title from a gz file:</p>
<pre><code>gunzip -c 150901_I188_FCC7F64ANXX_L3_wHAMPI021865-80_1.fq.gz | grep -A 3 &quot;HISEQ:378:C7F64ANXX:3:2109:10652:6636&quot; &gt;./found.1.fq
</code></pre>
<p>How to recursively delete a non-empty folder in Windows shell at the command prompt:</p>
<pre><code>rd /S /Q &quot;C:\path\to\folder&quot;
</code></pre>
<p>How to find orphaned/abandoned uploads/files in NodeBB:<br />
<a href="https://community.nodebb.org/topic/13698/a-way-for-clean-orphaned-files-images/2" rel="nofollow">ACP-&gt;Manage-&gt;Uploads-&gt;Check for 'orphaned' status-&gt;delete</a></p>
<ul>
<li>NB. You have to go through all the files listed and find the ones that are labelled 'orphaned'</li>
</ul>
<p>How to prevent empty line being inserted between divs in html:</p>
<pre><code>&lt;div style=&quot;padding:0;margin:0;clear:none;&quot;&gt;&lt;/div&gt;
&lt;div style=&quot;padding:0;margin:0;clear:none;&quot;&gt;&lt;/div&gt;
</code></pre>
<p>How to check how much space docker container logs are using:</p>
<pre><code>du -chs /var/lib/docker/containers/*/*json.log
</code></pre>
<p>How to store the output of a system call into a variable in Perl:</p>
<pre><code>my $com='ls';
my $variable=qx($com 2&gt;&amp;1);
</code></pre>
<p>How to retrieve paths to all container docker volumes on the host:</p>
<pre><code>docker inspect --format '{{range $mnt := .Mounts}} {{json $mnt.Source}} {{end}}' containerID
</code></pre>
<p>How to retrieve paths to one container docker volume on the host:</p>
<pre><code>docker inspect --format '{{ range .Mounts }}{{ if eq .Destination &quot;/data&quot; }}{{ .Source }}{{ end }}{{ end }}' containerID
</code></pre>
<p>How to find out how much space docker container log files are using:</p>
<pre><code>docker ps -qa | xargs docker inspect --format='{{.LogPath}}' | xargs sudo ls -hl
</code></pre>
<p>How to strip quotes surrounding a string in bash:</p>
<pre><code>volumePath='&quot;blah&quot;';
volumePath=$(eval echo $volumePath);
echo $volumePath
</code></pre>
<p>How to use CSS to hide html tags with href that start with some text and end with some text:</p>
<pre><code>a[href^=&quot;start_text&quot;][href$=&quot;end_text&quot;] {
    display: none; 
}
</code></pre>
<p>How to identify currency/money amounts/dollars with a regular expression in javascript:</p>
<pre><code>^[0-9]+(\.[0-9]{1,2})?$
</code></pre>
<p>How to identify alphanumeric characters in a regular expression with javascript:</p>
<pre><code>  this.match(/^[A-Za-z0-9]+$/);
</code></pre>
<p>How to remove all unused docker containers and volumes and networks:</p>
<pre><code>sudo docker system prune -a
sudo docker network prune
</code></pre>
<p>How to convert text in a text box or textarea into uppercase in html:</p>
<pre><code>text-transform: uppercase;
</code></pre>
<p>How to get a textarea in html to resize to the entered contents:</p>
<pre><code>&lt;script&gt;
    $(document).on('input', 'textarea', function () {
        $(this).outerHeight(38).outerHeight(this.scrollHeight); // 38 or '1em' -min-height
    }); 
&lt;/script&gt;
</code></pre>
<p>How to convert phred64 to phred33 in Perl and vice versa:</p>
<pre><code>$newqual = join( &quot;&quot;, map { chr( ord($_) - 64 + 33 ) } ( split( //, $oldqual ) ) );
$newqual = join( &quot;&quot;, map { chr( ord($_) - 33 + 64 ) } ( split( //, $oldqual ) ) );
</code></pre>
<p>How to find your stripe client id:</p>
<pre><code>https://dashboard.stripe.com/settings/applications
</code></pre>
<p>How to create an asynchronous code block in Node.js:</p>
<pre><code>(async () =&gt; { ... })();
</code></pre>
<p>How to use await Promise.all to wait for an asynchronous array to finish in Node.js before proceeding:</p>
<pre><code>/*This shows how to delete a list of files stored in a grid file system.*/
 
arrayOfFileNames=[&quot;file1.jpg&quot;, &quot;file2.jpg&quot;, &quot;file3.jpg&quot;];
 

async function asyncArrayWait(arrayOfFileNames) {
    try {
        await Promise.all(
            arrayOfFileNames.map(async (fileName) =&gt; {
                console.log('file name  '+fileName);
                await gfsRemoveAsync(fileName);
            }),
        );

        function gfsRemoveAsync(param){
            return new Promise((resolve,reject) =&gt; {
                gfs.remove(param, function(err){
                    if (err) {
                        reject(err);
                    }
                    else{
                        resolve('done');
                    }
                });
            });
        }
        
        console.log('All files in the array have now been deleted');
    }
    catch (error) {
    console.log('There was an error:  '+error);         
    }
}
</code></pre>
<p>How to sequentially perform functions using await in Node.js:</p>
<pre><code>let ID = '_idaghendhghner38393';

asyncRemoveStuff(ID);

async function asyncRemoveStuff(ID) {
    /* this function performs the three contained functions sequentially */
    try {

        /* This function depends on receiving the ID value from the parent function and returns its results in the obj2 variable*/

        let obj2= await gfsFindAsync({&quot;metadata.ID&quot;:ID});
        function gfsFindAsync(param){
            return new Promise((resolve,reject) =&gt; {
                gfs.files.find(param).toArray(function (err, obj) {
                    if (err) {
                        reject(err);
                    }
                    else{
                        resolve(obj);
                    }
                });
            });
        }



        /* This function depends on receiving the obj2 value from above*/

        await gfsRemoveAsync(obj2);
        function gfsRemoveAsync(param){
            return new Promise((resolve,reject) =&gt; {
                gfs.remove(param, function(err){
                    if (err) {
                        reject(err);
                    }
                    else{
                        resolve('done');
                    }
                });
            });
        }


        /* This function depends on receiving the ID value from the parent function*/

        await mongooseRemove({ 'info.ID' :  ID });
        function mongooseRemove(param){
            return new Promise((resolve,reject) =&gt; {
                MongooseDB.remove(param, function(err) {          
                    if (err){
                        reject(err);  
                    else{
                        let msg='Removed from the database';
                        resolve(msg)                        
                    }
                });
            });
        }
    }
    catch (error) {
        console.log('There was an error:  '+error);        
    }
}

</code></pre>
<p>How to randomly generate a grid of pixels image with javascript and canvas and post it as a value in a form:</p>
<pre><code>&lt;html&gt;
	&lt;body&gt;
		&lt;canvas id=&quot;myCanvas&quot; width=&quot;100&quot; height=&quot;100&quot; style=&quot;border:1px solid #d3d3d3;&quot;&gt;Your browser does not support the HTML5 canvas tag.&lt;/canvas&gt;

		&lt;form action=&quot;/fund-setup&quot; method=&quot;post&quot; enctype=&quot;multipart/form-data&quot;&gt;
			&lt;input type=&quot;hidden&quot; id=&quot;randomIcon&quot; name=&quot;randomIcon&quot; value=&quot;&quot;&gt;
			&lt;button type=&quot;submit&quot; &gt;Submit&lt;/button&gt;
		&lt;/form&gt;

		&lt;script&gt;
		  var canvas = document.getElementById('myCanvas'),ctx = canvas.getContext('2d'), x, y = 0, dim = canvas.width; ctx.translate(0.5, 0.5);                        
		  for(; y &lt; dim; y=y+20) {                          
		      for(x = 0; x &lt; dim; x=x+20) {
		          ctx.fillStyle = getRandomColor();          
		          ctx.fillRect(x, y, 20, 20);               
		      }
		  }
		  function getRandomColor() {
		      var r = 255*Math.random()|0,
		          g = 255*Math.random()|0,
		          b = 255*Math.random()|0;
		      return 'rgb(' + r + ',' + g + ',' + b + ')';
		  }
		  var canvasString = canvas.toDataURL();  
		  var randomIcon = document.getElementById('randomIcon');
		  randomIcon.value = canvas.toDataURL(&quot;image/jpeg&quot;, 0.5);        
		&lt;/script&gt;

	&lt;/body&gt;
&lt;/html&gt;

</code></pre>
<p>How to convert a callback function into a promise and use it with async await. This code must be contained within an async code block:</p>
<pre><code>let ID = '_idaghendhghner38393';

let obj2= await gfsFilesAsync({&quot;metadata.ID&quot;:ID});

function gfsFilesAsync(param){
    return new Promise((resolve,reject) =&gt; {
        gfs.files.find(param).toArray(function (err, obj) {
            if (err) {
                reject(err);
            }
            else{
                resolve(obj);
            }
        });
    });
}
</code></pre>
<p>How to use promise.all in an asynchronous code block to wait until an array of async functions complete:</p>
<pre><code>/*this is embedded in an async block*/
await Promise.all(
    fileNamesToDelete.map(async (ifile) =&gt; {
        /*the await below is important*/
        await gfsRemoveAsync({filename: ifile, root: 'images'});
        function gfsRemoveAsync(param){
            return new Promise((resolve,reject) =&gt; {
                gfs.remove(param, function (err) {
                    if (err) {
                        reject(err);
                    }
                    else{
                        resolve('done');
                    }
                });
            });
        }
    })
);

</code></pre>
<p>How to validate price fields with a regex:</p>
<pre><code>/^(\d*([.,](?=\d{3}))?\d+)+((?!\2)[.,]\d\d)?$/
</code></pre>
<p>How to specify the location of modules in Perl and Raku:</p>
<pre><code>#for the current directory
use lib '.' ;
#for the directory 'lib' in the current directory
use lib  'lib';
</code></pre>
<p>How to use functions from an external script in Node.js:</p>
<pre><code>#in external.js:
module.exports = function() { 
    this.add = function(a,b) { return a+b };
    this.divide = function(a,b) { return a/b };
    //etc
}

#in main.js:
require('external.js')();
add(1,2);
</code></pre>
<p>How to center test in markdown:</p>
<pre><code>&lt;p style=&quot;text-align: center;&quot;&gt;Centered text&lt;/p&gt;
</code></pre>
<p>How to convert a number to x decimal places in javascript:</p>
<pre><code>var cents=78.9
cents=cents.toFixed(2); //78.90
cents=78.997
cents=cents.toFixed(2); //79.00
</code></pre>
<p>How to launch the game of life with perl golf (no limits);</p>
<pre><code>perl -e '$c=q(((x7a/(x13)X4Ax!18)1817@0)4);$,=$/;$/=AX3AAAx76;$b=pack(&quot;(A)*&quot;,map{rand 3&lt;1}0..1816)x6;{print unpack&quot;(a79)23a0&quot;,$b;select$v,$v,$v,0.1;$b=pack&quot;(A)*&quot;,unpack&quot;$c&quot;,pack&quot;((a*)17xx!18)*&quot;,unpack&quot;x1737(AA$/Ax$/AA$/@)2222&quot;,$b;$a++;redo}'
</code></pre>
<p>How to launch the game of life with perl golf (with limits);</p>
<pre><code>perl -e '$a=0;$c=q(((x7a/(x13)X4Ax!18)1817@0)4);$,=$/;$/=AX3AAAx76;$b=pack(&quot;(A)*&quot;,map{rand 3&lt;1}0..1816)x6;{print unpack&quot;(a79)23a0&quot;,$b;select$v,$v,$v,0.1;$b=pack&quot;(A)*&quot;,unpack&quot;$c&quot;,pack&quot;((a*)17xx!18)*&quot;,unpack&quot;x1737(AA$/Ax$/AA$/@)2222&quot;,$b;$a++;redo if $a &lt;50;}'
</code></pre>
<p>How to control the width of a text box and make sure it is in the center of the page using inline CSS and html:</p>
<pre><code>&lt;input type=&quot;text&quot; style=&quot;max-width: 350px; margin:auto;&quot;  id=&quot;inputName&quot; name=&quot;inputName&quot;&gt;
</code></pre>
<p>How to dump a database from a non-standard port with mongodb:</p>
<pre><code>mongodump --port 87017 -d databaseName -o ./dump/databaseName-20200503
</code></pre>
<p>How to migrate a nodebb mongodb to a new server:</p>
<ul>
<li>Backup the nodebb database on the old server:</li>
</ul>
<pre><code>mongodump -u nodebb -p [password] -d nodebb -o dump/nodebb-2018-03-30
</code></pre>
<ul>
<li>On the new server, restore the nodebb database from the backup:</li>
</ul>
<pre><code>mongorestore -u nodebb -p [password] -d nodebb dump/nodebb-2018-03-30/nodebb/
</code></pre>
<ul>
<li>NB. It seems you have to reinstall/upgrade NodeBB after this, otherwise there are strange errors with pages not loading properly unless you reload them etc.</li>
</ul>
<p>How to find IP addresses of users who have successfully logged in to an Ubuntu/Debian server:</p>
<pre><code>zgrep sshd /var/log/auth.log* -h |grep -F 'Accepted'
</code></pre>
<p>How to recreate a Dockerfile from a docker image:</p>
<pre><code>#NB. unfortunatlely if an ADD or COPY command was used you cannot work out what files were added/copied
docker history --no-trunc=true image1 &gt; image1-dockerfile
</code></pre>
<p>How to get the IP address of a Docker container:</p>
<pre><code>docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $INSTANCE_ID
</code></pre>
<p>How to get the IP address of a running Docker container that has a hyphen in it's name and save it in a variable:</p>
<pre><code>IP=$(docker inspect --format '{{$network := index .NetworkSettings.Networks &quot;container-name_default&quot;}}{{$network.IPAddress}}' $(docker ps -q))
echo $IP
</code></pre>
<p>How to find an element in an array within an object and only display the desired element in MongoDB (the $ is important!):</p>
<pre><code>db.things.find({&quot;stuff.arraystuff&quot;: {&quot;$elemMatch&quot;: {&quot;ID&quot;: '1b6c0f70dd',&quot;nr&quot;:'908484f1127c'}}}, {&quot;stuff.arraystuff.$&quot;: 1})
</code></pre>
<p>How to reset/re-activate cut and paste function to/from VirtualBox linux guest and Windows host:</p>
<pre><code>#in linux guest:
killall VBoxClient
VBoxClient-all
</code></pre>
<p>How to draw on top of a pdf:</p>
<pre><code>Tools-&gt;Comment-&gt;[select pencil-drawing tool-icon]
</code></pre>
<p>How to load an R data file (.RData) into a variable in R:</p>
<pre><code>var1 &lt;-  get(load(&quot;D:/path/to/file.RData&quot;))
</code></pre>
<p>How to encode dummy variables in R using the Caret package:</p>
<pre><code>dummy_variablez &lt;- dummyVars(&quot; ~ .&quot;, data = variablez)
</code></pre>
<p>How to manually encode a dummy variable in R:</p>
<pre><code>df$female &lt;- ifelse(df$sex == female', 1, 0)
</code></pre>
<p>How to convert a range of columns in R to numeric (from character):</p>
<pre><code>#without dplyr:
dataz[,2:6] &lt;- sapply(dataz[,2:6],as.numeric)

#using dplyr:
if (!require(dplyr)) install.packages(&quot;dplyr&quot;)
library(dplyr)
library(dplyr)
dataz[,2:6] %&gt;% mutate_if(is.character,as.numeric)
</code></pre>
<p>How to change the label of a checkbox with JQuery:</p>
<pre><code>&lt;label id=&quot;lblfilter-green&quot; class=&quot;btn btn-outline-secondary btn-sm&quot;&gt;&lt;input type=&quot;checkbox&quot; name=&quot;direction&quot; id=&quot;filter-green&quot; /&gt;&lt;span&gt;&amp;nbsp;descending&lt;/span&gt;&lt;/label&gt;
&lt;script&gt;
    $('label').click(function () {
        var checked = $('input', this).is(':checked');
        $('span', this).text(checked ? ' ascending' : ' descending');
    });
&lt;/script&gt;
</code></pre>
<p>How to log into a screen session from multiple computers:</p>
<pre><code>screen -x nameofsession
</code></pre>
<p>How to preview an image after selecting it in html:</p>
<pre><code>&lt;img id=&quot;blah&quot; width=&quot;auto&quot; height=&quot;100&quot; /&gt;
&lt;input  type=&quot;file&quot; name=&quot;myTopImage&quot; onchange=&quot;document.getElementById('blah').src = window.URL.createObjectURL(this.files[0])&quot; /&gt;

</code></pre>
<p>How to submit a form when you select an image in html:</p>
<pre><code>&lt;input  type=&quot;file&quot; name=&quot;myImage&quot; onchange=&quot;form.submit()&quot; /&gt;
</code></pre>
<p>How to install local R packages in RStudio:</p>
<pre><code>if (!require(ThePackage)) install.packages(&quot;/path/to/the/package.tar.gz&quot;,repos = NULL, type=&quot;source&quot;)
</code></pre>
<p>How to remove the &quot;Powered by&quot; footer in NodeBB:</p>
<pre><code>ACP &gt; Extend &gt; Widgets, look at Global Footer.
</code></pre>
<p>How to process all files of a specific type in a specific directory using bash:</p>
<pre><code>	dir=&quot;.&quot;
	file=&quot;*.list&quot;
        #the if statement below prevents any error message if the file type doesn't exist
        if ls ${dir}/$file &gt;/dev/null  2&gt;&amp;1; then
	        for file in `cd ${dir};ls -1 ${file}` ;do
	           echo $file
	        done  
        fi
</code></pre>
<p>How to add elements to a list using a for loop in R:</p>
<pre><code>listz &lt;-rep(0,8)
for (i in 1:length(listz)){
  print(i)
  listz&lsqb;&lsqb;i&rsqb;&rsqb; &lt;- i

}
print(listz)

</code></pre>
<p>How to sort an object by keys in javascript:</p>
<pre><code>        //object is obj
	Object.keys(obj).sort()
      	.forEach(function(v, i) {
        	console.log(v, obj[v]);
       	});
</code></pre>
<p>How to calculate a floating point percentage (with eight digits) in bash from variables with bc and assign it's value to a variable in bash:</p>
<pre><code>PCT=`echo &quot;scale=8; ($NO / $TOTNO)*100&quot; | bc`
</code></pre>
<p>How to read all lines in a file including the last line without a newline character in bash:</p>
<pre><code>input=file.txt
while read line || [ -n &quot;$line&quot; ]
do
   echo $line
done &lt; $input
</code></pre>
<p>How to match fq, fastq,fq.gz,fastq.gz files with a regex in bash:</p>
<pre><code>fileFormat=&quot;$1&quot;

if &lsqb;&lsqb; $fileFormat =~ [Ff]([Aa][Ss][Tt])?[Qq](\.&lsqb;&lsqb;:alnum:&rsqb;&rsqb;+)?$ &rsqb;&rsqb;; then
    echo &quot;its a FASTQ file&quot;
else
    echo &quot;its not a FASTQ file&quot;
fi
</code></pre>
<p>How to calculate the length of multi-line fasta records in multi-fasta files using bash / awk:</p>
<pre><code>awk '/^&gt;/{if (l!=&quot;&quot;) print l; print; l=0; next}{l+=length($0)}END{print l}' ./sequence.fasta
</code></pre>
<p>How to get the nextflow_dir path of the previous container in Nextflow and delete a file in it:</p>
<pre><code>#in the previous container set the file in an output command:
output:
     set file(&quot;${pair_id}_raw_snps_${round}.vcf&quot;) into raw_snps_ch

#in the next container set a val with an input command:
input:
     val(raw_snps) from raw_snps_ch

#In the script section, the $raw_snps variable will have the full path of the file in the nextflow_dir folder. You can then delete it:
script:
'''     
rm $raw_snps
'''
</code></pre>
<p>How to count the number of folders in a path in bash (i.e the number of levels in a directory structure) and store it in a variable:</p>
<pre><code>varz=`echo &quot;/directory/structure/&quot; | tr &quot; /&quot; &quot;- &quot; | wc -w`
</code></pre>
<p>How to untar a tar.gz file and omit the preceding directory structure:</p>
<pre><code>#first count the number of levels in the preceding directory structure to be omitted
varz=`echo &quot;/preceding/directory/structure/to be omitted/&quot; | tr &quot; /&quot; &quot;- &quot; | wc -w`
#in this case we are extracting it into a directory that is the same as the preceding directory to be omitted
#in addition we are using the k option so that extracting does not overwrite existing files/folders
tar --strip-components $varz -C /preceding/directory/structure/to be omitted/ -zxvkf /tarfile/tobeextracted.tar.gz

</code></pre>
<p>How to sort all columns in a pandas dataframe and reset the index in Python:</p>
<pre><code>   df.sort_values(by=df.columns.to_list(), axis=0, ascending=True, inplace=True, kind='quicksort', na_position='last')
   df=df.reset_index(drop=True)
</code></pre>
<p>How to transpose a 2D array in Python:</p>
<pre><code>2d=[
['A', 'B', 'C', 'D'],
['E', 'F', 'G', 'H'],
['I', 'J', 'K', 'L']
]

2dStar=list(zip(*2d))
print(2dStar)

</code></pre>
<p>How to create multiple columns at once in a dataframe with Python and Pandas using series:</p>
<pre><code>'''
Starting DF:
   A  B
0  6  1
1  8  4
Desired DF:
   A  B  C   D
0  6  1  16  56
1  8  4  18  58
'''
def myfunc1(row):
    C = row['A'] + 10
    D = row['A'] + 50
    return pd.Series([C, D])

df&lsqb;&lsqb;'C', 'D'&rsqb;&rsqb; = df.apply(myfunc1 ,axis=1)
</code></pre>
<p>How to apply a function over multiple columns in a Python Pandas dataframe to create a new column:</p>
<pre><code>import pandas as pd

df = pd.DataFrame({'ID':['1', '2', '3'], 'col_1': [0, 2, 3], 'col_2':[1, 4, 5]})
mylist = ['a', 'b', 'c', 'd', 'e', 'f']

def get_sublist(sta,end):
    return mylist[sta:end+1]

df['col_3'] = df.apply(lambda x: get_sublist(x['col_1'], x['col_2']), axis=1)

'''
Output:
  ID  col_1  col_2      col_3
0  1      0      1     [a, b]
1  2      2      4  [c, d, e]
2  3      3      5  [d, e, f]
'''
</code></pre>
<p>How to do matrix multiplication with a for loop or the numpy dot function (faster) in Python:</p>
<pre><code>   import numpy as np

    np.random.seed(seed)
    A = np.random.rand(n,n)
    B = np.random.rand(n,n)
    C = np.zeros((n,n))

    #With for loop:

    for i in range(n):
        for j in range(n):
            for k in range(n):
                C[i,j] += A[i,k]*B[k,j]

    #With dot function:

    C += A.dot(B)
                

</code></pre>
<p>How to initialise values in a dictionary in Python with defaultdict:</p>
<pre><code>from collections import defaultdict

D2 = defaultdict(int) 

#note below you don't first have to initialise the value to 0
D2['new-key'] += 1

print(D2)
</code></pre>
<p>How to iterate a list to get the index and value using the enumerate function in Python:</p>
<pre><code>for indexz,valuez in enumerate(listz):
    print(indexz,valuez)
</code></pre>
<p>How to split a string up into individual characters in Python:</p>
<pre><code>#the list function does this if given a string
stringz='atcgcgta'
listz=list(stringz)

</code></pre>
<p>How to cut a string at a range of positions provided as a list in Python:</p>
<pre><code>def get_slices(s, l):
    l = [0] + l + [len(s)]
    cut =[s[x:y] for x,y in zip(l, l[1:])]
    return cut

s='GCATAGTAATGTATTAATGGC'
l=[7, 15]
sliced=get_slices(s,l)
</code></pre>
<p>How to return the indexes of values in a list that pass a condition in Python:</p>
<pre><code>lz=[6, 9, 10, 6, 12]
newList = [ i for i,t in enumerate(lz) if t  &gt;= 9]
</code></pre>
<p>How to check if an element occurs in a list in Python:</p>
<pre><code>ex='slot'
listz=['luck', 'slot', 'just', 'opened', 'kitchen']
if ex in listz:
    print (&quot;found in list &quot;,ex)
if ex not in listz:
    print (ex,&quot; is not in the list &quot;)
</code></pre>
<p>How to retrieve key:value pairs from a dictionary that has keys common with another dictionary in Python:</p>
<pre><code>d1={'a':1,'c':1}
d2={'a':1,'b':1,'c':1}
common_dict = {x:d1[x] for x in d1 if x in d2} 
</code></pre>
<p>How to retrieve keys common to two dictionaries in Python 3:</p>
<pre><code>x={'a':1,'c':1}
y={'a':1,'b':1,'c':1}
for key in x:
    if key in y:
        print (key, x[key])
</code></pre>
<p>How to sort a dictionary in descending order by it's values and retrieve the first k pairs in Python:</p>
<pre><code>sorted_dictz=sorted(dictz.items(), key=lambda x: x[1], reverse=True)[:k]

</code></pre>
<p>How to get a list of indices of x elements with the highest values from a list in Python:</p>
<pre><code>x=5
listz=[1,6,3,9,6,7,6,8,3,5]
top_5_element_indexes = sorted(range(len(listz)), key = lambda sub: listz[sub])[-x:]
</code></pre>
<p>How to sum all the values in a 'value column' of a pandas dataframe according to strings in a 'key column' and then use those summed total values to create a new column that contains the value/total_value fraction for each occurence of the key in the original 'key column' :</p>
<pre><code>tot_value=df.groupby('key')['value'].sum()
df['fraction']=df.apply(lambda x: x['value']/tot_value[x['key'&rsqb;&rsqb;, axis=1)
</code></pre>
<p>How to compare two Pandas dataframes and retrieve the differences:</p>
<pre><code>#you can also have sort=False
pd.concat([df1, df2],sort=True).drop_duplicates(keep=False)
</code></pre>
<p>How to retrieve the first n elements of a set:</p>
<pre><code>for n,elem in enumerate(set_name):
    if n == 5:
        break
    print (elem)
</code></pre>
<p>How to simultaneously iterate through multiple lists of the same length in Python:</p>
<pre><code>    for r,c,v in zip(list1,list2,list3):
        print(&quot;r:&quot;,r)
        print(&quot;c:&quot;,c)
        print(&quot;v:&quot;,v)

</code></pre>
<p>How to sort and find unique elements in a list in Python (2 methods):</p>
<pre><code>    method1=sorted(set(listz))
    method2=sorted([*{*listz}])
</code></pre>
<p>How to do element-wise multiplication of two lists to create a new list in Python:</p>
<pre><code>newlist=[i * j for i, j in zip(list1, list2)]
</code></pre>
<p>How to merge two Pandas dataframes using columns with different names in Python:<br />
<img src="https://shanelynnwebsite-mid9n9g1q9y8tt.netdna-ssl.com/wp-content/uploads/2017/03/pandas-merge-join-different-variable-names-copy-e1488722312527.jpg" alt="alt text" class="img-responsive img-markdown" /></p>
<pre><code>df3=pd.merge(df1,df2&lsqb;&lsqb;'Code','Desc'&rsqb;&rsqb;,left_on='ID',right_on='Code',how='inner')
</code></pre>
<p>How to generate a random matrix of defined shape with floating point numbers between a minimum and maximum value  in Python with numpy:</p>
<pre><code>import numpy as np
m,n=(3,4)
min,max=-2.5,3.4
rand_matrix=np.random.uniform(min,max,(m*n)).reshape(m,n)
</code></pre>
<p>How to concatenate Python pandas dataframes with different column names and remove indexes:</p>
<pre><code>import numpy as np
#this trick uses numpy to remove the column names and indexes
df = pd.DataFrame( np.concatenate( (df1.values, df2.values), axis=0 ) )
#add column names in as a final step
df.columns = [ 'a', 'x', 'y' ]

</code></pre>
<p>How to retrieve multiple columns of a pandas dataframe by their name using regex:</p>
<pre><code>dfSub=df.filter(regex = 'City|Country|Region')
</code></pre>
<p>How to convert dates to timestamps (down to sub millisecond resolution) in a Python Pandas dataframe:</p>
<pre><code>df['Timestamp']=pd.to_datetime(df['Date'],errors='coerce')
df['Timestamp'] = df['Timestamp'].dt.strftime('%Y-%m-%d %H:%M:%S:%f')
</code></pre>
<p>How to concatenate multiple pandas dataframe columns in python:</p>
<pre><code>newdf =pd.concat([df['col1'], df['col2'],df2['col1'],df2['col2'&rsqb;&rsqb;, axis=1, ignore_index=True)
</code></pre>
<p>How to filter Python pandas dataframe by multiple conditions:</p>
<pre><code>is_1 = (df[&quot;Col1&quot;] == &quot;hello&quot;)
is_2 = (df[&quot;Col2&quot;] == &quot;is_it_me&quot;)
df_fil=df[is_1 &amp; is_2]
</code></pre>
<p>How to do left, right, inner and outer joins in Python with pandas dataframes:<br />
<img src="https://www.datasciencemadesimple.com/wp-content/uploads/2017/06/merge-in-R-2.jpg" alt="alt text" class="img-responsive img-markdown" /><br />
<img src="https://shanelynnwebsite-mid9n9g1q9y8tt.netdna-ssl.com/wp-content/uploads/2017/02/pd-merge_intro_image-e1488724380571.png" alt="alt text" class="img-responsive img-markdown" /></p>
<pre><code>#outer merge:
result = pd.merge(user_usage,
                 user_device&lsqb;&lsqb;'use_id', 'platform', 'device'&rsqb;&rsqb;,
                 on='use_id')
#left merge:
result = pd.merge(user_usage,
                 user_device&lsqb;&lsqb;'use_id', 'platform', 'device'&rsqb;&rsqb;,
                 on='use_id', 
                 how='left')
</code></pre>
<p>How to rename a column in a Python pandas dataframe:</p>
<pre><code>data.rename(columns={'gdp':'log(gdp)'}, inplace=True)
</code></pre>
<p>How to remove / drop multiple columns in a Python pandas dataframe:</p>
<pre><code>result.drop(['Name1','Name2'], axis=1, inplace=True)

#OR:
del df_states[&quot;Name1&quot;]
del df_states[&quot;Name2&quot;]
</code></pre>
<p>How to copy a Python pandas dataframe:</p>
<pre><code>df2=df.copy(deep=True)
</code></pre>
<p>How to extract only column 1 and 2 from a Python pandas dataframe and group by values in column 1 and then sum the aggregated column 2 values into a column named 'count' and then sort them in descending order:</p>
<pre><code>    sum_sorted_grouped_df = df&lsqb;&lsqb;'Col1','Col2'&rsqb;&rsqb;.groupby(['Col1'])['Col2'] \
                         .sum() \
                         .reset_index(name='count') \
                         .sort_values(['count'], ascending=False)
</code></pre>
<p>How to sort a Python pandas dataframe by values in two separate columns (the first ascending and the second descending):</p>
<pre><code>df.sort_values(['b', 'c'], ascending=[True, False], inplace=True)
</code></pre>
<p>How to change the dtype of a Python pandas dataframe column:</p>
<pre><code>df['Colz']=df['Colz'].astype('float64')
</code></pre>
<p>How to create a dictionary from two columns in a Python pandas dataframe:</p>
<pre><code>dictz=dict(zip(df['col1'],df['col2']))
</code></pre>
<p>How to create an empty pandas dataframe with column names in Python:</p>
<pre><code>column_names = [&quot;a&quot;, &quot;b&quot;, &quot;c&quot;]
df = pd.DataFrame(columns = column_names)
</code></pre>
<p>How to create a dictionary from an anonymous list in Python:</p>
<pre><code>a=dict(&lsqb;&lsqb;'w',1],['y',2&rsqb;&rsqb;)
print(a)
#{'w': 1, 'y': 2}
</code></pre>
<p>How to generate consecutive pairs from a list in Python:</p>
<pre><code>l = [1, 7, 3, 5]
for first, second in zip(l, l[1:]):
    print (first, second)

#1 7
#7 3
#3 5
</code></pre>
<p>How to generate pairs from two columns in a Python pandas dataframe and assign them as values using keys in another column:</p>
<pre><code>#generate pairs from two columns:
 zipz=zip(df['col2'],df['col3'])
#create dictionary with keys in another column
 dictz=dict( zip( df['col1'],zipz))
#output:
#{0: (999, 556), 1: (153, 995), 2: (679, 075)}

</code></pre>
<p>How to generate a COO matrix of m by n dimensions in Python with Scipy:</p>
<pre><code>R = [0, 0, 1, 1, 2, 2]
C = [1, 2, 0, 1, 0, 1]
V = [5, 2, 1, 1, 6, 1]
import scipy.sparse as sp
coo_matrix((V, (R, C)), shape=(n, m))
</code></pre>
<p>How to do COO and CSR matrix multiplication with Python Scipy:</p>
<pre><code>import numpy as np
import scipy.sparse as sp

R = [0, 0, 1, 1, 2, 2]
C = [1, 2, 0, 1, 0, 1]
V = [5, 2, 1, 1, 6, 1]
P=  [0,    2,    4,   6]

x = [1, 2, 3]

x = np.ones(num_verts)

#COO
COO = sp.coo_matrix((V, (R, C)))
COO.dot(x)

#CSR
CSR = A_coo_sp.tocsr() # or...    sp.csr_matrix((V,C,P))
CSR.dot(x)
</code></pre>
<p>How to write a function and apply it to a Python numpy matrix using vectorize:</p>
<pre><code>    Y = np.array(&lsqb;&lsqb;5, 2, 0],
                  [2, 4, 7&rsqb;&rsqb;)
    print(Y)
    #&lsqb;&lsqb;5 2 0]
    # [2 4 7&rsqb;&rsqb;
    def myfunc(a):
        #Return 1 if a&gt;0, otherwise return 0
        if a &gt; 0:
            return 1
        else:
            return 0
    vfunc = np.vectorize(myfunc)
    
    A=vfunc(Y)
    print(A)

    #&lsqb;&lsqb;1 1 0]
    # [1 1 1&rsqb;&rsqb; 


</code></pre>
<p>How to remove duplicated rows in a pandas dataframe in python:</p>
<pre><code>df.drop_duplicates(subset = None, inplace=True)
</code></pre>
<p>How get the index positions of elements in a numpy array that satisfy a filter condition using the 'where' function in Python and use them to retrieve their corresponding values:</p>
<pre><code>x = np.array([-4, 4, 5])
from numpy import where
k = where(x &gt; 0)[0]
#k=[1 2]
y=x[k]
#y=[4,5]

</code></pre>
<p>How to create an empty array in numpy using the empty() function in Python:</p>
<pre><code>#The values in the array are whatever is located in that memory address at the time.
#This is quicker than creating an array of zeros
from numpy import empty, arange
kx = empty(10, dtype=int)
print(kx)
</code></pre>
<p>How to use a list of index positions to reorder values in a Python numpy array:</p>
<pre><code>indexes=[4,3,2,1,0]
values=[10,9,8,7,6]
new=np.array([0] * len(values))
new[indexes]=values
print (new)
#[ 6  7  8  9 10]
</code></pre>
<p>How to get a list of index positions (array3) of elements in an array (array 1) that match elements in another array (array2) using numpy and Python:</p>
<pre><code>import numpy as np
array1=np.array([0,3,5,6,9,1,2,4,7,8])
#empty, dtype=int creates a list of length n. It has values equal to whatever was at that memory address at the time)
#as an alternative to empty() you could use:
#array3=np.array([0] * len(array1))
#however it is slower
array3 = empty(len(array1), dtype=int)
array2=np.array([0,1,2,3,4,5,6,7,8,9])
#The line below is where the magic happens. TBH I'm not so sure why it works, however it is not the same as array3=array1[array2]
array3[array1] = array2
print(array3)
#[0 5 6 1 7 2 3 8 9 4]


</code></pre>
<p>How to count the occurences of a string in a column of a Python pandas dataframe:</p>
<pre><code>counts = df['TITLE'].value_counts()
</code></pre>
<p>How to randomly pick a sample of fixed size from a numpy array in Python (without replacement):</p>
<pre><code>import numpy as np
population=np.array([0,1,2,3,4,5,6,7,8,9])
samplez = choice(population, size=5, replace=False)
</code></pre>
<p>How to reverse an array in Python using a subscript with two colons followed by minus 1:</p>
<pre><code>#b is the reverse of a
b=a[::-1]
</code></pre>
<p>How to get a list of indexes of an array in the order they would be in if the array values were sorted:</p>
<pre><code>x = np.array([3, 1, 2])
np.argsort(x)
#[1, 2, 0]
</code></pre>
<p>How to concatenate strings in two separate columns of a pandas dataframe in Python:</p>
<pre><code>df['concat']=df['col1']+'_'+df['col2']
</code></pre>
<p>How to calculate the mean of numpy arrays while ignoring any nan values in Python:</p>
<pre><code>arrayz= np.array(&lsqb;&lsqb;np.nan,  21.85, np.nan], [  6.95, np.nan, -31.55&rsqb;&rsqb;)
meanz=np.nanmean(arrayz)
</code></pre>
<p>How to create a comment block in a bash script:</p>
<pre><code>: &lt;&lt;'END'
comments go here
END

</code></pre>
<p>How to clear the contents of a text file in Python:</p>
<pre><code>open('output.txt', 'w').close()
</code></pre>
<p>How to remove a file extension and store it in a variable  in bash:</p>
<pre><code>filename='file.txt'
base=${filename%.*}
echo $base
#file
</code></pre>
<p>How to convert a Nextflow array into a bash array within a NextFlow shell script block:</p>
<pre><code>#reads='[1.fastq.gz, 2.fastq.gz]'
#remove square brackets
nfarray=\$(echo &quot;${reads//[][,!]}&quot;)
#split at commas
arr=(`echo \$nfarray | cut -d &quot;,&quot;  --output-delimiter=&quot; &quot; -f 1-`)
#print out first element
echo &quot;\${arr[0]}&quot;


#######################
#NB. When I retested the above code I seemed to get an error. Upon further testing it seemed that you can directly use nextflow arrays thus:

for filename in ${reads}; do
	filename=\$(echo &quot;\${filename//[][,!]}&quot;)
	echo \$(basename \${filename})
done

</code></pre>
<p>How to filter vcf files with bcftools:</p>
<pre><code>#http://samtools.github.io/bcftools/bcftools.html#expressions
bcftools filter --regions-file $pathToBed/BEDFILE.bed $inputVCF | bcftools filter -e &quot;QUAL &lt; 10 || F_MISSING &gt; 0.01 || MAF &gt; 0.98&quot; | bcftools view -m2 -M2 -v snps --output-type z --output-file $outputDIR/$name._filtered.vcf.gz | bcftools index -t --output-file $outputDIR/$name._filtered.vcf.gz.tbi
</code></pre>
<p>How to use eval in Perl to execute text as code:</p>
<pre><code>$name='yes';
$reg='s/yes/no/g';
my $code='$name'.' =~ '.$reg.';';
eval($code);
print &quot;$name\n&quot;;
#no

</code></pre>
<p>How to use bash to find the longest common substring between two strings:</p>
<pre><code>				word1=$b1
				word2=$b2
				if [ ${#word1} -lt ${#word2} ]
				then
					word1=$b2
					word2=$b1
				fi
				comsub=''
				for ((i=${#word2}; i&gt;0; i--)); do
					for ((j=0; j&lt;=${#word2}-i; j++)); do
						if &lsqb;&lsqb; $word1 =~ ${word2:j:i} &rsqb;&rsqb;
						then
							echo ${word2:j:i}
							comsub=${word2:j:i}
							break 2
						fi
					done
				
				done
</code></pre>
<p>How to only move a file if it exists in bash:</p>
<pre><code>[ ! -f a.txt ] || mv a.txt b.txt
</code></pre>
<p>How to use eval to process regular expressions supplied as text strings in Perl:</p>
<pre><code>my $string='cat';
my $reg='s/a/un/';
my $code='$string'.' =~ '.$reg.';';
eval($code);
</code></pre>
<p>How to use grep to find a regex in a directory of gzipped files in linux:</p>
<pre><code>find /path/to/dire -name \*.gz -print0 | xargs -0 zgrep -n -E 'GCGT|N|Y|y|W|w|K|k|V|v|U|u'
</code></pre>
<p>How to use bash with paste and shuf to randomly shuffle paired fastq files:</p>
<pre><code>paste &lt;(zcat test.2.fq.gz) &lt;(zcat test.2.fq.gz) | paste - - - - | shuf | awk -F'\t' '{OFS=&quot;\n&quot;; print $1,$3,$5,$7 &gt; &quot;random.1.fq&quot;; print $2,$4,$6,$8 &gt; &quot;random.2.fq&quot;}'
</code></pre>
<p>How to extract specific lines from an archived gzipped gz file (and print out the line numbers):</p>
<pre><code>gunzip -c file.gz | awk -v from=10 -v to=20 'NR&gt;=from { print NR,$0; if (NR&gt;=to) exit 1}'
</code></pre>
<p>How to strip leading and trailing quotes from a string in Python:</p>
<pre><code>    if (string[0] == string[-1]) and string.startswith((&quot;'&quot;, '&quot;')):
        string=string[1:-1]
</code></pre>
<p>How to get the path, file name, base name and extension in bash:</p>
<pre><code>full_name=&quot;/foo/fuzz.bar&quot;
file_name=$(basename ${full_name})
base_name=${file_name%%.*}
extension=&quot;${filename##*.}&quot;
path=${full_name##*/}
</code></pre>
<p>How to process samples with multiple paired reads per sample using NextFlow:</p>
<p><a href="https://stackoverflow.com/questions/69702077/nextflow-how-to-process-multiple-samples" rel="nofollow">https://stackoverflow.com/questions/69702077/nextflow-how-to-process-multiple-samples</a></p>
<p>How to change a NextFlow/Groovy channel variable in a script and then put it back in a channel (file method):</p>
<pre><code>	process changer {
		cpus 1
		memory '1 GB'
		time '1m'
	   input:
			val(variable1) from ch1
			
		output:
			file(*) into ch2
		script:

			&quot;&quot;&quot;
			echo &quot;variable1 is: &quot;$variable1
			variable2=&quot;hello: $variable1&quot;
			touch \$variable2
			&quot;&quot;&quot;
	}

	process reintroducer {
		cpus 1
		memory '1 GB'
		time '1m'
		
	        input:
			//How to get the base filename without extensions in Nextflow with simpleName
			val(variable3) from ch2.map { file -&gt; file.simpleName }		
		output:
			val (variable3) into ch3
		script:
			&quot;&quot;&quot;
			echo &quot;variable3 is:&quot;$variable3
			&quot;&quot;&quot;
	}
</code></pre>
<p>How to apply a regex to a channel variable in NextFlow:</p>
<pre><code>
	process getSimpleName {
		//scratch true
		cpus 4
		memory { 0.GB +(24.GB * task.attempt) }	
		time { 14.hour + (8.hour * task.attempt) }
		errorStrategy { (task.exitStatus in 1..272 &amp;&amp; task.attempt &lt;= maxRetries)  ? 'retry' : 'terminate' }
		maxRetries 5	


		input:
			val(modified_names) from original_names_ch.map ({ varz -&gt; varz.replaceFirst(/\*\//,&quot;&quot;).replaceAll(&quot;\\.txt&quot;, &quot;&quot;) })


		output:			
			val(modified_names) into modified_names_ch


		script:
			&quot;&quot;&quot;
                        echo &quot;stripped proceeding paths and txt file extension to create &quot;$modified_names
			&quot;&quot;&quot;
	}
</code></pre>
<p>How to write a regex to identify all word characters (including _) in a variable in bash:</p>
<pre><code>string='abcd123'
regex='([_[:alnum:&rsqb;&rsqb;)'
				
if &lsqb;&lsqb; &quot;$string&quot; =~ $regex &rsqb;&rsqb;; then
    echo &quot;word characters found&quot;
fi					
</code></pre>
<p>How to test for the existence of unzipped or gzipped fasta files using a Perl one-liner:</p>
<pre><code>		flag=`perl -e 'BEGIN {$t=shift};my $fz=0;  if($t =~ /\.(fa|fasta|fa\.gz|fasta\.gz)$/){$fz=1};print &quot;$fz&quot;' ${file} `
			
		echo &quot;flag is: &quot;$flag
</code></pre>
<p>How to alphanumerically sort files that end with a number and store the results in a bash array using a Perl one-liner:</p>
<pre><code>#NB print0 appends null to the end. Consequently .$ must be present in the statement map {/(\d+).$/; [$_, $1];}
array3=(&quot;`find ${input} -type d  -mindepth 2  -print0 | perl -e '$/=&quot;\0&quot;; my @files=&lt;&gt;; my @sorted_array = map { $_-&gt;[0] } sort { $a-&gt;[1] &lt;=&gt; $b-&gt;[1]} map {/(\d+).$/; [$_, $1];} @files; print &quot;@sorted_array&quot;;'`&quot;)
</code></pre>
<p>How to get file attributes such as basename and filesize in NextFlow:<br />
<a href="https://www.nextflow.io/docs/latest/script.html#check-file-attributes" rel="nofollow">https://www.nextflow.io/docs/latest/script.html#check-file-attributes</a></p>
<p>How to collect all of the files produced by a NextFlow process and analyse each of them individually in separate processes:</p>
<pre><code>	process createFiles{
		cache false
		cpus 2
		memory '4 GB'
		time '4h'

		input:
			val(refz) from ref_ch2
			set val(pair_id), val(input_bam) from bam_for_intervals.mix(bam_for_intervals2).mix(bam_for_intervals3)	

		output:
		
			path (&quot;./intervals/*.list&quot;) into intz_ch
			val (input_bam) into bam_for_variant_calling
			
		publishDir &quot;${params.intervals}&quot;, mode:'move'
		
		script:
			scriptdir=params.scripts
			intervaldir=params.intervals

			&quot;&quot;&quot;
			filename=$input_bam
			filename=\$(echo &quot;\${filename//[][,!]}&quot;)		
			b1=\$(basename \$filename)
			input_bamz=${params.bam}/\${b1}
			
			dir=$params.ref
			filed=&quot;*.fa&quot;
			for file in `cd \${dir};ls -1 \${filed}` ;do
			   rf=$params.ref/\$file
			done			
			base=\${rf%.*}
			refdict=&quot;\${base}.dict&quot;	
			refname=\$(basename \$file)
			perl $scriptdir/fastaq2bed/fastaq2bed.plx  -i \$rf -o \$rf   || true
			java -jar \$PICARD_JAR BedToIntervalList \
				  I=\${rf}.bed \
				  O=\${refname}.interval_list \
				  SD=\${refdict}	
			perl $scriptdir/perl_mutect2/perl_mutect2.plx  -q \${rf} -i \${input_bamz} -s \${refname}.interval_list -x 'intervals'  -k ${params.max_interval_bp} -o ./   || true	  
			#dir=&quot;./intervals&quot;
			#filed=&quot;*.list&quot;
			#for file in `cd \${dir};ls -1 \${filed}` ;do
			   #mv \${dir}/\${file} &quot;${params.intervals}/&quot;
			#done 
				  
			&quot;&quot;&quot;
	}

process indexer {
	//NB. pgen_ch2 does not increment if cache is not set to false and is therefore essential
	//cache false
	//scratch true

	cpus 1
	memory '2 GB'
	time '1h'

    input:
		each (input_interval) from intz_ch.collect()
    output:	
		file (&quot;*.list&quot;) into pgen_ch3
    script:
	
    &quot;&quot;&quot;
		
		echo &quot;input_interval is ${input_interval}&quot;
		file_name=\$(basename ${input_interval})
		echo &quot;file_name is \${file_name}&quot;
		touch \${file_name}
    &quot;&quot;&quot;
}

process haplotypeCaller {
	scratch true
	cpus 4
	memory { 0.GB +(24.GB * task.attempt) }	
    time { 14.hour + (8.hour * task.attempt) }
    errorStrategy { (task.exitStatus in 1..272 &amp;&amp; task.attempt &lt;= maxRetries)  ? 'retry' : 'terminate' }
    maxRetries 5	

    input:
		set val(refz), val(bam_name), val(input_interval) from ref_ch3.combine(bam_for_variant_calling.combine(pgen_ch3))

    script:
		round=1
		&quot;&quot;&quot;
		
		echo &quot;input_interval is &quot;${input_interval}
		echo &quot;bam_name is &quot;${bam_name}
		ref_name=\$(basename ${refz})
		ref_base=\${ref_name%%.*}
		ref=\${ref_base}		
		
		file_name=\$(basename ${bam_name})
		base_name=\${file_name%%.*}
		pair_id=\${base_name}
		
		echo &quot;pair_id is &quot; \${pair_id}
		inz=&quot;${input_interval}&quot;
		interval_base_name=\${inz%%.*}
		interval_num=&quot;\$interval_base_name&quot;
		regex='([0-9]+).list'
		&lsqb;&lsqb; \$interval_num =~ \$regex &rsqb;&rsqb;
		echo \${BASH_REMATCH[1]}
		
		
		if [ &quot;$params.doJointCallingBQSR&quot; == &quot;true&quot; ] || [ &quot;$params.doJointCalling&quot; == &quot;true&quot; ]; then
			echo &quot;Doing joint calling&quot;
			gatk HaplotypeCaller \
			-R \$ref \
			-I ${params.bam}/$bam_name \
			-L ${params.intervals}/\$interval_base_name \
			--emit-ref-confidence GVCF \
			-O ${params.vcf}/\${pair_id}_raw_variants_${round}_\${BASH_REMATCH[1]}.g.vcf
		else	
			echo &quot;Not doing joint calling&quot;
			gatk HaplotypeCaller \
			-R \$ref \
			-I ${params.bam}/$bam_name \
			-L ${params.intervals}/\$interval_base_name \
			-O ${params.vcf}/\${pair_id}_raw_variants_${round}_\${BASH_REMATCH[1]}.vcf 
		fi
		&quot;&quot;&quot;
}
</code></pre>
<p>How to calculate md5 hash for a file in windows:</p>
<pre><code>certutil -hashfile file.txt MD5
</code></pre>
<p>How to calculate the md5 checksum for all files of a certain type in a folder using the Windows command line cmd.exe:</p>
<pre><code>#set the target folder, file type and output folder and paste the code below into the cmd shell.
#md5 checksums are written to \output_folder\md5.txt for each file and then sorted and an md5 checksum is created from the sorted text file
#The final results are in \output_folder\md5_final.txt
set &quot;target_folder=E:\test&quot;
set &quot;file_type=*.txt&quot;
set &quot;output_folder=E:&quot;
type NUL &gt; %output_folder%\md5.txt
for /R %target_folder% %f in (%file_type%) do @certutil -hashfile &quot;%f&quot; MD5  | findstr /V &quot;:&quot; &gt;&gt;%output_folder%\md5.txt
sort /M 10240 %output_folder%\md5.txt &gt; %output_folder%\md5_sorted.txt &amp; certutil -hashfile %output_folder%\md5_sorted.txt MD5 &gt; %output_folder%\md5_final.txt

</code></pre>
<p>How to search for a file and retrieve it's path in linux:</p>
<pre><code>find / -name 'libperl.so'  -exec readlink -f {} \;
</code></pre>
<p>How to print @INC with a perl one-liner:</p>
<pre><code>perl -e 'print &quot;@INC&quot;'
</code></pre>
<p>How to check for a matching file extension in bash:</p>
<pre><code>echo &quot;file name is read1.gz&quot;
if [ &quot;${read1##*.}&quot; = &quot;gz&quot; ]; then
    echo &quot;this is a gz file&quot;
fi
</code></pre>
<p>How to check if a specific file type / file extension exists in a directory in bash:</p>
<pre><code>dir=&quot;/path/to/dir&quot;
file=&quot;*.txt&quot;
if ls ${dir}/$file &gt;/dev/null  2&gt;&amp;1; then
   echo $file&quot; exists&quot;
fi
</code></pre>
<p>How to set the contents of a channel into two separate channels in Nextflow:</p>
<pre><code>Channel.fromPath(&quot;${params.path}/*.*cf&quot;).into({channel_1;channel2})

</code></pre>
<p>How to fix the error</p>
<p>[0m/.singularity.d/actions/exec: exec: line 9: /bin/bash: not found</p>
<p>with NextFlow and singularity containers built on alpine linux:</p>
<ul>
<li>Install bash when building the container</li>
</ul>
<pre><code>RUN apk add bash
</code></pre>
<p>How to make a NextFlow file channel send an empty file with a specific filename (&quot;empty_file&quot;) if the channel is empty:</p>
<pre><code>Channel.fromPath( &quot;/home/*.{txt,pdf}&quot; ).ifEmpty(file(&quot;empty_file&quot;)).set { new_ch }
</code></pre>
<p>How to remove the file extension from a filename generated by a path channel in NextFlow:</p>
<pre><code>val(ext) from ch.map({path -&gt; path.getFileName().normalize().toString().split(/\./)[0]})

#if you get the error &quot;Unknown method invocation `getName` on ArrayList type&quot;. Try the following:

val(ext) from ch.map({path -&gt; path[-1].getFileName().normalize().toString().split(/\./)[0]})

</code></pre>
<p>How to remove the preceding file path and get the base name from a filename generated by a path channel in NextFlow:</p>
<pre><code>val(basename) from ch.map({path -&gt; path.getFileName().normalize().toString().split(/\//)[-1]})

</code></pre>
<p>How to separate each element of an array in a file channel into individual channels in Nextflow. (This example also converts file paths to base names):</p>
<pre><code>#flatten may not always be required
each (val) from ch.map ({ file -&gt; file.simpleName }).flatten()

</code></pre>
<p>How to modify just one element of an array in a channel in NextFlow:</p>
<pre><code>#for the output channel of the previous process:
set val(val1), val(val2), file (&quot;*.txt&quot;) into output_ch


#for the input channel of the next process (this modifies the third element to get the file name of a file). Note how square brackets must be put around the output if you don't want the input flattened:

set val(valz1), val(valz2), val(filez) from output_ch.map ({ val1, val2, file -&gt; [pair_id, round, file.getName()] })
</code></pre>
<p>How to copy files from a docker container using a wildcard:</p>
<pre><code>#the secret is to use a . instead of *
docker cp container_id:/container_folder/. ./host_folder/
</code></pre>
<p>How to do non-integer maths in bash with bc and get an answer with a leading 0 in front of the decimal point and 6 decimal places and save it into a bash variable:</p>
<pre><code>rd1=&quot;scale=6; ${P}/${tot_reads}&quot;
rd2=`printf '%.6f' &quot;$(echo $rd1 | bc)&quot;`
</code></pre>
<p>How to increment a counter in Bash:</p>
<pre><code>COUNT=$((COUNT+1))
</code></pre>
<p>How to create an array in Bash by splitting a comma delimited string and then increment each value in the string by accessing each array element by it's index:</p>
<pre><code>UM='1,2,3,4,5,6'
UPM=($(echo $UM | tr &quot;,&quot; &quot;\n&quot;))

AM=''
for i in ${!UPM[*]}; do 
	echo ${UPM[$i]}
	ADDZ=`echo ${UPM[$i]}+1 | bc`
	AM=${AM}','${ADDZ}
done
	
UMF=`echo $AM | sed 's/^,//'`
</code></pre>
<p>How to delete all text in Vi text editor:</p>
<pre><code>:1,$d.
</code></pre>
<p>How to enter insert mode in Vi editor:</p>
<pre><code>press 'i'
</code></pre>
<p>How to exit insert mode in Vi editor:</p>
<pre><code>press 'esc'
</code></pre>
<p>How to save and exit in Vi editor:</p>
<pre><code>:wq! and enter
</code></pre>
<p>How to exit without saving in Vi editor:</p>
<pre><code>:q! and enter
</code></pre>
<p>How to pipe to and from bcftools using STDIN and STDOUT (standard input and standard output):</p>
<pre><code>#Ou is critical for STDOUT and - is critical for STDIN
bcftools norm -d none ./infile.vcf.gz -Ou | bcftools sort - –T ./temp -Oz -o ./outfile.vcf.gz
</code></pre>
<p>How to use brace expansion in bash to use ls to list all files that match multiple different patterns:</p>
<pre><code>pattern1='*.zip'
pattern2='*.gz'
dir='/bin'
filez=`echo {${pattern1},${pattern2}}`
#you could also use: filez=`echo {*.zip,*.gz}`
echo &quot;filez is: &quot;$filez
for file in `cd ${dir};ls ${filez} 2&gt;/dev/null` ;do
	echo \$file
done
				
</code></pre>
<p>How to replace non-printable characters in Perl (2 methods):</p>
<pre><code>#Method 1:
$v =~ s/\P{IsPrint}//g;
#Method 2:
$v =~ tr[\0-\x08\x0B\x0C\x0E-\x1F\x7F][\x{2400}-\x{2408}\x{240B}\x{240C}\x{240E}-\x{241F}\x{2421}];
</code></pre>
<p>How to use an IF statement in a Nextflow process to choose between two different input channels using a ternary operator:</p>
<pre><code>#uses ch1 if params.use_ch1 is true
val(A) from (params.use_ch1 == &quot;true&quot; ? ch1 : ch2)
</code></pre>
<p>How to convert a file containing channel generated by a NextFlow process to a value containing channel:</p>
<pre><code>
process generate{
	input:
		val (in) from in_ch
	output:
		file(&quot;*.{txt,doc}&quot;) into chz
	script:
		&quot;&quot;&quot;
		echo &quot;$in&quot;
		touch a.txt
		touch b.doc
		&quot;&quot;&quot;
}
//The channel ch1 now contains the filename surrounded by []
ch1=chz.collect ({ it.getName() })

process analyse{
	input:
		//flatten is required to remove the surrounding [] (and to launch one process per file name)
		val (valz) from ch1.flatten()
	script:
		&quot;&quot;&quot;
		echo &quot;$valz&quot;
		&quot;&quot;&quot;
}
</code></pre>
<p>How to do division in bash and give an answer as a whole number rounded up and store it in a variable:</p>
<pre><code>mem=24
cpuz=9
memz=`echo &quot;scale=0; (($mem + 0.5)/ $cpuz)&quot; | bc`
</code></pre>
<p>How to combine multiple Nextflow channels together into one channel:</p>
<pre><code>input:
	val(mixed) from ch1.collect().mix(ch2.collect()).mix(ch3.collect()).mix(ch4.collect()).collect()
</code></pre>
<p>How to mount another filesystem to a container (eg. Singularity) in a Nextflow process:</p>
<pre><code>process foo{
	containerOptions{
		//the folder specified in params.inFolder is mounted to /home in the container
		//NB perhaps be careful to not to mount such a large folder
		&quot;-B ${absolutePath('params.inFolder')}:/home&quot;
	}
	input:
		val (in) from in_ch
	output:
		file(&quot;*.txt&quot;) into out_ch

	```
	touch file.txt

	```

}
</code></pre>
<p>How to store a value from a script into a nextflow channel (this hasn't been tested):</p>
<pre><code>process myProcess {

   input:
      val (in) from inChannel

    output:
       shell '''
       echo &quot;Hello world!&quot;
       echo &quot;This is a multiline command.&quot;
       ''' into outChannel
}
</code></pre>
<p>How to re-enable the bi-directional clipboard in virtualbox with a xubuntu guest:</p>
<pre><code>systemctl restart vboxadd-service
#alternatively try:
sudo VBoxClient --clipboard
</code></pre>
<p>How to remove tabs between double quotes in a tab-separated file using a regular expression in Perl:</p>
<pre><code>#This assumes you cannot have escaped quotes inside your quotes. And that your fields themselves do not contain quotes.
$line = join &quot;&quot;, map {my $_ = $_; /^&quot;/ &amp;&amp; s/\t+//g; $_} $line =~ /&quot;[^&quot;]*&quot;|[^&quot;]*/g;
</code></pre>
]]></description><link>https://links.sharezomics.com/post/224</link><guid isPermaLink="true">https://links.sharezomics.com/post/224</guid><dc:creator><![CDATA[Matt]]></dc:creator><pubDate>Fri, 18 Aug 2023 12:16:21 GMT</pubDate></item><item><title><![CDATA[Reply to How to... on Thu, 09 May 2019 02:49:35 GMT]]></title><description><![CDATA[<p>How to set an access policy in Amazon Web Services to only allow read/write access to a single bucket:</p>
<p>############################################################<br />
#address: <a href="https://s3.amazonaws.com/bucket-name" rel="nofollow">https://s3.amazonaws.com/bucket-name</a><br />
#Settings for cyberduck<br />
#server: <a href="http://s3.amazonaws.com" rel="nofollow">s3.amazonaws.com</a><br />
#path: /bucket-name/<br />
############################################################</p>
<pre><code>{
    &quot;Id&quot;: &quot;p1&quot;,
    &quot;Version&quot;: &quot;2012-10-17&quot;,
    &quot;Statement&quot;: [
        {
            &quot;Sid&quot;: &quot;sp1&quot;,
            &quot;Action&quot;: [
                &quot;s3:GetObject&quot;,
                &quot;s3:ListBucket&quot;,
                &quot;s3:PutObject&quot;
            ],
            &quot;Effect&quot;: &quot;Allow&quot;,
            &quot;Resource&quot;: [
                &quot;arn:aws:s3:::bucket-name&quot;,
                &quot;arn:aws:s3:::bucket-name/*&quot;
            ]
        }
    ]
}
</code></pre>
]]></description><link>https://links.sharezomics.com/post/271</link><guid isPermaLink="true">https://links.sharezomics.com/post/271</guid><dc:creator><![CDATA[Matt]]></dc:creator><pubDate>Thu, 09 May 2019 02:49:35 GMT</pubDate></item><item><title><![CDATA[Reply to How to... on Fri, 31 May 2019 03:53:54 GMT]]></title><description><![CDATA[<p>How to combine characters with unicode diacritical marks and print them out in Perl.</p>
<p>Perl code must contain:</p>
<pre><code>use open qw(:std :utf8);
</code></pre>
<p>To combine the character with the mark you have to use the 3 digits following the 0x0 prefix in the first column of the table below. You code it in the following way:</p>
<pre><code>print &quot;A\x{302}\n&quot;;
</code></pre>
<p>will print out:</p>
<pre><code>Â
</code></pre>
<p>Multiple marks can be used:</p>
<pre><code>print &quot;A\x{302}\x{32A}\n&quot;;
</code></pre>
<p><strong>Diacritical Marks Table:</strong></p>
<pre><code>
Position	Decimal	Name	Appearance
0x0300	768	COMBINING GRAVE ACCENT	̀
0x0301	769	COMBINING ACUTE ACCENT	́
0x0302	770	COMBINING CIRCUMFLEX ACCENT	̂
0x0303	771	COMBINING TILDE	̃
0x0304	772	COMBINING MACRON	̄
0x0305	773	COMBINING OVERLINE	̅
0x0306	774	COMBINING BREVE	̆
0x0307	775	COMBINING DOT ABOVE	̇
0x0308	776	COMBINING DIAERESIS	̈
0x0309	777	COMBINING HOOK ABOVE	̉
0x030A	778	COMBINING RING ABOVE	̊
0x030B	779	COMBINING DOUBLE ACUTE ACCENT	̋
0x030C	780	COMBINING CARON	̌
0x030D	781	COMBINING VERTICAL LINE ABOVE	̍
0x030E	782	COMBINING DOUBLE VERTICAL LINE ABOVE	̎
0x030F	783	COMBINING DOUBLE GRAVE ACCENT	̏
0x0310	784	COMBINING CANDRABINDU	̐
0x0311	785	COMBINING INVERTED BREVE	̑
0x0312	786	COMBINING TURNED COMMA ABOVE	̒
0x0313	787	COMBINING COMMA ABOVE	̓
0x0314	788	COMBINING REVERSED COMMA ABOVE	̔
0x0315	789	COMBINING COMMA ABOVE RIGHT	̕
0x0316	790	COMBINING GRAVE ACCENT BELOW	̖
0x0317	791	COMBINING ACUTE ACCENT BELOW	̗
0x0318	792	COMBINING LEFT TACK BELOW	̘
0x0319	793	COMBINING RIGHT TACK BELOW	̙
0x031A	794	COMBINING LEFT ANGLE ABOVE	̚
0x031B	795	COMBINING HORN	̛
0x031C	796	COMBINING LEFT HALF RING BELOW	̜
0x031D	797	COMBINING UP TACK BELOW	̝
0x031E	798	COMBINING DOWN TACK BELOW	̞
0x031F	799	COMBINING PLUS SIGN BELOW	̟
0x0320	800	COMBINING MINUS SIGN BELOW	̠
0x0321	801	COMBINING PALATALIZED HOOK BELOW	̡
0x0322	802	COMBINING RETROFLEX HOOK BELOW	̢
0x0323	803	COMBINING DOT BELOW	̣
0x0324	804	COMBINING DIAERESIS BELOW	̤
0x0325	805	COMBINING RING BELOW	̥
0x0326	806	COMBINING COMMA BELOW	̦
0x0327	807	COMBINING CEDILLA	̧
0x0328	808	COMBINING OGONEK	̨
0x0329	809	COMBINING VERTICAL LINE BELOW	̩
0x032A	810	COMBINING BRIDGE BELOW	̪
0x032B	811	COMBINING INVERTED DOUBLE ARCH BELOW	̫
0x032C	812	COMBINING CARON BELOW	̬
0x032D	813	COMBINING CIRCUMFLEX ACCENT BELOW	̭
0x032E	814	COMBINING BREVE BELOW	̮
0x032F	815	COMBINING INVERTED BREVE BELOW	̯
0x0330	816	COMBINING TILDE BELOW	̰
0x0331	817	COMBINING MACRON BELOW	̱
0x0332	818	COMBINING LOW LINE	̲
0x0333	819	COMBINING DOUBLE LOW LINE	̳
0x0334	820	COMBINING TILDE OVERLAY	̴
0x0335	821	COMBINING SHORT STROKE OVERLAY	̵
0x0336	822	COMBINING LONG STROKE OVERLAY	̶
0x0337	823	COMBINING SHORT SOLIDUS OVERLAY	̷
0x0338	824	COMBINING LONG SOLIDUS OVERLAY	̸
0x0339	825	COMBINING RIGHT HALF RING BELOW	̹
0x033A	826	COMBINING INVERTED BRIDGE BELOW	̺
0x033B	827	COMBINING SQUARE BELOW	̻
0x033C	828	COMBINING SEAGULL BELOW	̼
0x033D	829	COMBINING X ABOVE	̽
0x033E	830	COMBINING VERTICAL TILDE	̾
0x033F	831	COMBINING DOUBLE OVERLINE	̿
0x0340	832	COMBINING GRAVE TONE MARK	̀
0x0341	833	COMBINING ACUTE TONE MARK	́
0x0342	834	COMBINING GREEK PERISPOMENI	͂
0x0343	835	COMBINING GREEK KORONIS	̓
0x0344	836	COMBINING GREEK DIALYTIKA TONOS	̈́
0x0345	837	COMBINING GREEK YPOGEGRAMMENI	ͅ
0x0346	838	COMBINING BRIDGE ABOVE	͆
0x0347	839	COMBINING EQUALS SIGN BELOW	͇
0x0348	840	COMBINING DOUBLE VERTICAL LINE BELOW	͈
0x0349	841	COMBINING LEFT ANGLE BELOW	͉
0x034A	842	COMBINING NOT TILDE ABOVE	͊
0x034B	843	COMBINING HOMOTHETIC ABOVE	͋
0x034C	844	COMBINING ALMOST EQUAL TO ABOVE	͌
0x034D	845	COMBINING LEFT RIGHT ARROW BELOW	͍
0x034E	846	COMBINING UPWARDS ARROW BELOW	͎
0x0360	864	COMBINING DOUBLE TILDE	͠
0x0361	865	COMBINING DOUBLE INVERTED BREVE	͡
0x0362	866	COMBINING DOUBLE RIGHTWARDS ARROW BELOW	͢
</code></pre>
]]></description><link>https://links.sharezomics.com/post/289</link><guid isPermaLink="true">https://links.sharezomics.com/post/289</guid><dc:creator><![CDATA[Matt]]></dc:creator><pubDate>Fri, 31 May 2019 03:53:54 GMT</pubDate></item><item><title><![CDATA[Reply to How to... on Fri, 26 Jul 2019 23:09:29 GMT]]></title><description><![CDATA[<p>How to change ownership of a topic/first post in NodeBB:</p>
<ul>
<li>Login to mongo and select the nodebb db:</li>
</ul>
<pre><code>mongo --port 27017
use nodebb

</code></pre>
<ul>
<li>Find the object containing the title of the Topic and note down the &quot;mainPid&quot; value of the first post (49 in the example below):</li>
</ul>
<pre><code>&gt; db.objects.find({&quot;title&quot;:&quot;Party&quot;},{&quot;content&quot;:0}).pretty()
</code></pre>
<pre><code>{
	&quot;_id&quot; : ObjectId(&quot;5ce891520ff514295e68ba97&quot;),
	&quot;_key&quot; : &quot;topic:32&quot;,
	&quot;tid&quot; : 32,
	&quot;uid&quot; : 18,
	&quot;cid&quot; : 19,
	&quot;mainPid&quot; : &quot;49&quot;,
	&quot;title&quot; : &quot;Party&quot;,
	&quot;slug&quot; : &quot;32/party&quot;,
	&quot;timestamp&quot; : 1558745426311,
	&quot;lastposttime&quot; : 1559511732448,
	&quot;postcount&quot; : 3,
	&quot;viewcount&quot; : 19,
	&quot;locked&quot; : 0,
	&quot;deleted&quot; : 0,
	&quot;pinned&quot; : 0,
	&quot;thumb&quot; : &quot;&quot;,
	&quot;teaserPid&quot; : 72
}
{
	&quot;_id&quot; : ObjectId(&quot;5cf0b04e60bb27abedd56188&quot;),
	&quot;_key&quot; : &quot;event:821&quot;,
	&quot;type&quot; : &quot;post-purge&quot;,
	&quot;uid&quot; : 18,
	&quot;pid&quot; : &quot;60&quot;,
	&quot;ip&quot; : &quot;137.154.34.129&quot;,
	&quot;tid&quot; : 32,
	&quot;title&quot; : &quot;Party&quot;,
	&quot;timestamp&quot; : 1559277646867,
	&quot;eid&quot; : 821
}
</code></pre>
<ul>
<li>Find the &quot;uid&quot; of the user you wish to change ownership to (19 in the example below):</li>
</ul>
<pre><code>&gt; db.objects.find({&quot;username&quot;:&quot;Harry&quot;}).pretty()
</code></pre>
<pre><code>{
	&quot;_id&quot; : ObjectId(&quot;5cf4420b60bb27abedd56383&quot;),
	&quot;_key&quot; : &quot;user:19&quot;,
	&quot;username&quot; : &quot;Harry&quot;,
	&quot;userslug&quot; : &quot;harry&quot;,
	&quot;email&quot; : &quot;harry@harry.com&quot;,
	&quot;joindate&quot; : 1559511563818,
	&quot;lastonline&quot; : 1559512762482,
	&quot;picture&quot; : &quot;&quot;,
	&quot;fullname&quot; : &quot;harry_mcboatface&quot;,
	&quot;location&quot; : &quot;&quot;,
	&quot;birthday&quot; : &quot;&quot;,
	&quot;website&quot; : &quot;&quot;,
	&quot;signature&quot; : &quot;&quot;,
	&quot;uploadedpicture&quot; : &quot;&quot;,
	&quot;profileviews&quot; : 2,
	&quot;reputation&quot; : 0,
	&quot;postcount&quot; : 3,
	&quot;topiccount&quot; : 0,
	&quot;lastposttime&quot; : 1559512083251,
	&quot;banned&quot; : 0,
	&quot;status&quot; : &quot;online&quot;,
	&quot;gdpr_consent&quot; : 0,
	&quot;acceptTos&quot; : 0,
	&quot;uid&quot; : 19,
	&quot;ldapid&quot; : 4028644545,
	&quot;rss_token&quot; : &quot;340dc97c-0586-4ecd-8584-2241d106ce03&quot;
}

</code></pre>
<ul>
<li>Use the &quot;uid&quot; value from above (19) to update the &quot;cid&quot; and &quot;uid&quot; values of the topic</li>
</ul>
<pre><code>&gt; db.objects.update({ &quot;title&quot;:&quot;Party&quot; },{$set: { &quot;cid&quot; : 19 }})
&gt; db.objects.update({ &quot;title&quot;:&quot;Party&quot; },{$set: { &quot;uid&quot; : 19 }})
</code></pre>
<ul>
<li>Use the &quot;uid&quot; value from above (19) to update the first post from above (&quot;pid&quot; 49)</li>
</ul>
<pre><code>&gt; db.objects.update({ &quot;pid&quot;: 49 },{$set: { &quot;uid&quot; : 19 }})
</code></pre>
<ul>
<li>If you want to be very thorough you can update the uid of the post edit history. Find all edit 'eid' values shown after running the very first command in this post :</li>
</ul>
<pre><code>db.objects.find({&quot;title&quot;:&quot;Party&quot;},{&quot;content&quot;:0}).pretty()
</code></pre>
<p>          and update their uid:</p>
<pre><code>db.objects.update({ &quot;eid&quot;: 821 },{$set: { &quot;uid&quot; : 19 }})
</code></pre>
<ul>
<li>You then change the uid of all posts in the topic by inspecting the html of each post for the uid in your browser (eg. in chrome on windows right-click the post and choose inspect from the pull down menu):</li>
</ul>
<p><img src="/assets/uploads/files/1564114516604-find_pid.jpg" alt="find_pid.jpg" class="img-responsive img-markdown" /></p>
<ul>
<li>Then use the following code in mongo to update the uid for that pid:</li>
</ul>
<pre><code>db.objects.update({ &quot;pid&quot;: 299 },{$set: { &quot;uid&quot; : 19 }})

</code></pre>
<ul>
<li>You need to rebuild and restart the database using the Admin Control Panel (ACP) for the changes to take effect.</li>
</ul>
]]></description><link>https://links.sharezomics.com/post/290</link><guid isPermaLink="true">https://links.sharezomics.com/post/290</guid><dc:creator><![CDATA[Matt]]></dc:creator><pubDate>Fri, 26 Jul 2019 23:09:29 GMT</pubDate></item><item><title><![CDATA[Reply to How to... on Wed, 05 Jun 2019 09:18:32 GMT]]></title><description><![CDATA[<p>How to view Microsoft Word documents online in NodeBB:</p>
<pre><code>[normal link](/assets/uploads/files/1559590085004-test-word-document.docx)

[viewable link](https://view.officeapps.live.com/op/view.aspx?src=https%3A%2F%2Flinks.sharezomics.com%2Fassets%2Fuploads%2Ffiles%2F1559590085004-test-word-document.docx)
</code></pre>
<p><a href="/assets/uploads/files/1559590085004-test-word-document.docx">normal link</a></p>
<p><a href="https://view.officeapps.live.com/op/view.aspx?src=https%3A%2F%2Flinks.sharezomics.com%2Fassets%2Fuploads%2Ffiles%2F1559590085004-test-word-document.docx" rel="nofollow">viewable link</a></p>
]]></description><link>https://links.sharezomics.com/post/292</link><guid isPermaLink="true">https://links.sharezomics.com/post/292</guid><dc:creator><![CDATA[Matt]]></dc:creator><pubDate>Wed, 05 Jun 2019 09:18:32 GMT</pubDate></item><item><title><![CDATA[Reply to How to... on Thu, 11 Jul 2019 10:55:35 GMT]]></title><description><![CDATA[<p>How to rip/copy DVD's to your hard drive:</p>
<p><strong>Method 1</strong> (NB. Had problems with out of sync voices with this one)</p>
<ul>
<li>
<p>Download and install VLC media player.</p>
</li>
<li>
<p>Run VLC media player.</p>
</li>
<li>
<p>Insert DVD.</p>
</li>
<li>
<p>In VLC media player, click Media, and then click Convert / Save... The Open Media window opens.</p>
</li>
<li>
<p>Tick 'No disc menus' and raise the Title number to 1</p>
</li>
</ul>
<p><img src="/assets/uploads/files/1561867628955-vlc1.jpg" alt="vlc1.jpg" class="img-responsive img-markdown" /></p>
<ul>
<li>
<p>Click Convert / Save.</p>
</li>
<li>
<p>Click the additional settings button:</p>
</li>
</ul>
<p><img src="/assets/uploads/files/1561867637323-vlc2.jpg" alt="vlc2.jpg" class="img-responsive img-markdown" /></p>
<ul>
<li>Choose Ogg/Ogm encapsulation:</li>
</ul>
<p><img src="/assets/uploads/files/1561867645274-vlc3.jpg" alt="vlc3.jpg" class="img-responsive img-markdown" /></p>
<ul>
<li>Choose MPEG-4 Video codec:</li>
</ul>
<p><img src="/assets/uploads/files/1561867656009-vlc4.jpg" alt="vlc4.jpg" class="img-responsive img-markdown" /></p>
<ul>
<li>Click save and provide a Destination file name</li>
<li>Click Start</li>
</ul>
<p><strong>Method 2 (better)</strong></p>
<ul>
<li>
<p>Download and install adware free version of ImgBurn 2.5.8.0 from:<br />
<a href="https://www.majorgeeks.com/files/details/imgburn.html" rel="nofollow">https://www.majorgeeks.com/files/details/imgburn.html</a></p>
</li>
<li>
<p>Select 'Create image file from disc'</p>
</li>
<li>
<p>Right click on the *.ISO file and choose 'mount'</p>
</li>
<li>
<p>Open the VIDEO_TS.IFO file with VLC media player</p>
</li>
</ul>
]]></description><link>https://links.sharezomics.com/post/299</link><guid isPermaLink="true">https://links.sharezomics.com/post/299</guid><dc:creator><![CDATA[Matt]]></dc:creator><pubDate>Thu, 11 Jul 2019 10:55:35 GMT</pubDate></item><item><title><![CDATA[Reply to How to... on Tue, 02 Jul 2019 08:29:25 GMT]]></title><description><![CDATA[<p>How to organise NodeBB sub-categories into columns with CSS:</p>
<pre><code>.category-children .category-children-item {
    float: left ;
    width: 20em ;
}
</code></pre>
]]></description><link>https://links.sharezomics.com/post/300</link><guid isPermaLink="true">https://links.sharezomics.com/post/300</guid><dc:creator><![CDATA[Matt]]></dc:creator><pubDate>Tue, 02 Jul 2019 08:29:25 GMT</pubDate></item><item><title><![CDATA[Reply to How to... on Sun, 11 Aug 2019 10:23:24 GMT]]></title><description><![CDATA[<p>How to install TensorFlow with GPU support on Windows 10:</p>
<p><a href="https://www.pugetsystems.com/labs/hpc/How-to-Install-TensorFlow-with-GPU-Support-on-Windows-10-Without-Installing-CUDA-UPDATED-1419/" rel="nofollow">https://www.pugetsystems.com/labs/hpc/How-to-Install-TensorFlow-with-GPU-Support-on-Windows-10-Without-Installing-CUDA-UPDATED-1419/</a></p>
]]></description><link>https://links.sharezomics.com/post/319</link><guid isPermaLink="true">https://links.sharezomics.com/post/319</guid><dc:creator><![CDATA[Matt]]></dc:creator><pubDate>Sun, 11 Aug 2019 10:23:24 GMT</pubDate></item><item><title><![CDATA[Reply to How to... on Wed, 04 Sep 2019 03:53:17 GMT]]></title><description><![CDATA[<p>How to convert a docker image to a singularity image:</p>
<pre><code>docker run \
  -v /var/run/docker.sock:/var/run/docker.sock \
  -v D:\host\path\where\to\output\singularity\image:/output \
  --privileged -t --rm \
  filo/docker2singularity \
  ubuntu:14.04
</code></pre>
<p>Replace D:\host\path\where\to\output\singularity\image with a path in the host filesystem where your Singularity image will be created. Replace ubuntu:14.04 with the docker image name you wish to convert (it will be pulled from Docker Hub if it does not exist on your host system).</p>
<p>You can read more and submit issues or patches at <a href="https://github.com/chrisfilo/docker2singularity" rel="nofollow">https://github.com/chrisfilo/docker2singularity</a></p>
]]></description><link>https://links.sharezomics.com/post/324</link><guid isPermaLink="true">https://links.sharezomics.com/post/324</guid><dc:creator><![CDATA[Matt]]></dc:creator><pubDate>Wed, 04 Sep 2019 03:53:17 GMT</pubDate></item><item><title><![CDATA[Reply to How to... on Fri, 20 Sep 2019 21:47:09 GMT]]></title><description><![CDATA[<p>How to filter mapped/unmapped fastq reads:</p>
<ul>
<li>get all the reads where both mapped:</li>
</ul>
<pre><code>samtools view -F 12 bothEndsMapped.bam
</code></pre>
<ul>
<li>get all the reads that did not map, but whose mate mapped:</li>
</ul>
<pre><code>samtools view  -F 4 -f 8 onlyThisEndMapped.bam
</code></pre>
<ul>
<li>get all the reads that mapped, but whose mates did not:</li>
</ul>
<pre><code>samtools view -F 8 -f 4 onlyThatEndMapped.bam
</code></pre>
<ul>
<li>get all the reads where neither one mapped:</li>
</ul>
<pre><code>samtools view -f 12 neitherEndMapped.bam
</code></pre>
]]></description><link>https://links.sharezomics.com/post/325</link><guid isPermaLink="true">https://links.sharezomics.com/post/325</guid><dc:creator><![CDATA[Matt]]></dc:creator><pubDate>Fri, 20 Sep 2019 21:47:09 GMT</pubDate></item><item><title><![CDATA[Reply to How to... on Mon, 23 Sep 2019 23:29:22 GMT]]></title><description><![CDATA[<p>How to write nodejs async/await code:</p>
<pre><code>// With function declaration
async function myFn() {
  // await ...
}
// With arrow function
const myFn = async () =&gt; {
  // await ...
}
</code></pre>
<p><a href="https://blog.bitsrc.io/understanding-javascript-async-and-await-with-examples-a010b03926ea" rel="nofollow">Source </a></p>
]]></description><link>https://links.sharezomics.com/post/389</link><guid isPermaLink="true">https://links.sharezomics.com/post/389</guid><dc:creator><![CDATA[Matt]]></dc:creator><pubDate>Mon, 23 Sep 2019 23:29:22 GMT</pubDate></item><item><title><![CDATA[Reply to How to... on Tue, 13 Oct 2020 22:44:59 GMT]]></title><description><![CDATA[<p>How to display the contents of a circular JSON object in nodejs:</p>
<p>Method1:</p>
<pre><code>		const getCircularReplacer = () =&gt; {
		  const seen = new WeakSet();
		  return (key, value) =&gt; {
		    if (typeof value === &quot;object&quot; &amp;&amp; value !== null) {
		      if (seen.has(value)) {
		        return;
		      }
		      seen.add(value);
		    }
		    return value;
		  };
		};

		var string=JSON.stringify(circularJSONobject, getCircularReplacer());
		console.log(string);

</code></pre>
<p>Method 2:</p>
<pre><code class="language-{js}">var util = require('util'); //a core nodejs function but it has to be imported
console.log(util.inspect(circularJSONobject));
</code></pre>
]]></description><link>https://links.sharezomics.com/post/401</link><guid isPermaLink="true">https://links.sharezomics.com/post/401</guid><dc:creator><![CDATA[Matt]]></dc:creator><pubDate>Tue, 13 Oct 2020 22:44:59 GMT</pubDate></item><item><title><![CDATA[Reply to How to... on Sun, 29 Dec 2019 02:41:24 GMT]]></title><description><![CDATA[<p>How to create post buttons that look like links:</p>
<p>css:</p>
<pre><code>  .link-button {
    background: none;
    border: none;
    color: #337ab7;
    cursor: pointer;
    font-size: 19px;
    font-weight: 400;
    font-family: 'Lato', sans-serif;
  }
  .link-button:focus {
    outline: none;
  }
  .link-button:active {
    color:red;
  }
  .link-button:hover {
    text-decoration: underline;
    filter: brightness(65%);
  }
</code></pre>
<p>html:</p>
<pre><code>&lt;form method=&quot;post&quot; action=&quot;https://mics.com/index&quot; class=&quot;inline&quot;&gt;
&lt;button type=&quot;submit&quot; name=&quot;submit_name&quot; value=&quot;name&quot; class=&quot;link-button&quot;&gt;link display text&lt;/button&gt;
&lt;/form&gt;
</code></pre>
]]></description><link>https://links.sharezomics.com/post/402</link><guid isPermaLink="true">https://links.sharezomics.com/post/402</guid><dc:creator><![CDATA[Matt]]></dc:creator><pubDate>Sun, 29 Dec 2019 02:41:24 GMT</pubDate></item><item><title><![CDATA[Reply to How to... on Wed, 23 Oct 2019 04:37:55 GMT]]></title><description><![CDATA[<p>How to display line numbers for pasted code in NodeBB:</p>
<p>This is from <a href="https://community.nodebb.org/topic/10469/any-code-format-plugin/3" rel="nofollow">here</a>.</p>
<p>NB. (This isn't working for me)</p>
<p>Put this in your custom header (ACP -&gt; Appearance -&gt; Custom HTML &amp; CSS -&gt; Custom Header):</p>
<pre><code>&lt;script&gt;
require(['highlight'], function (hljs) {
  require([
    'https://cdnjs.cloudflare.com/ajax/libs/highlightjs-line-numbers.js/1.1.0/highlightjs-line-numbers.min.js'
  ], function () {
    $(window).on('load action:ajaxify.end', function () {
      setTimeout(function () {
        hljs.initLineNumbersOnLoad();
      }, 100);
    });
  });
});
&lt;/script&gt;
</code></pre>
<p>NB. The contents of 'highlightjs-line-numbers.min.js' are:</p>
<pre><code>!function(e){&quot;use strict&quot;;function t(){&quot;complete&quot;===document.readyState?n():e.addEventListener(&quot;DOMContentLoaded&quot;,n)}function n(){try{var e=document.querySelectorAll(&quot;code.hljs&quot;);for(var t in e)e.hasOwnProperty(t)&amp;&amp;r(e[t])}catch(n){console.error(&quot;LineNumbers error: &quot;,n)}}function r(e){if(&quot;object&quot;==typeof e){var t=e.parentNode,n=o(t.textContent);if(n&gt;1){for(var r=&quot;&quot;,c=0;n&gt;c;c++)r+=c+1+&quot;\n&quot;;var l=document.createElement(&quot;code&quot;);l.className=&quot;hljs hljs-line-numbers&quot;,l.style[&quot;float&quot;]=&quot;left&quot;,l.textContent=r,t.insertBefore(l,e)}}}function o(e){if(0===e.length)return 0;var t=/\r\n|\r|\n/g,n=e.match(t);return n=n?n.length:0,e[e.length-1].match(t)||(n+=1),n}&quot;undefined&quot;==typeof e.hljs?console.error(&quot;highlight.js not detected!&quot;):(e.hljs.initLineNumbersOnLoad=t,e.hljs.lineNumbersBlock=r)}(window);
</code></pre>
]]></description><link>https://links.sharezomics.com/post/403</link><guid isPermaLink="true">https://links.sharezomics.com/post/403</guid><dc:creator><![CDATA[Matt]]></dc:creator><pubDate>Wed, 23 Oct 2019 04:37:55 GMT</pubDate></item><item><title><![CDATA[Reply to How to... on Wed, 30 Oct 2019 05:23:16 GMT]]></title><description><![CDATA[<p>How to cycle/loop through an object in javascript:</p>
<pre><code>for (var key in req.body) {
    if (key in req.body) {
        console.log(req.body[key]);
    }
}
</code></pre>
]]></description><link>https://links.sharezomics.com/post/407</link><guid isPermaLink="true">https://links.sharezomics.com/post/407</guid><dc:creator><![CDATA[Matt]]></dc:creator><pubDate>Wed, 30 Oct 2019 05:23:16 GMT</pubDate></item><item><title><![CDATA[Reply to How to... on Fri, 22 Nov 2019 05:47:23 GMT]]></title><description><![CDATA[<p><strong>%(#ffffff)[How to publish a package with npm:]</strong></p>
<p>*Sign in with npm login:</p>
<pre><code>npm login
</code></pre>
<p>You’ll be prompted to enter your username, password, and email address.</p>
<p>*Create a folder named how-to-publish-to-npm:</p>
<pre><code>mkdir how-to-publish-to-npm
</code></pre>
<p>*Navigate into the folder:</p>
<pre><code>cd how-to-publish-to-npm
</code></pre>
<p>*Begin the project with the npm init command:</p>
<pre><code>npm init
</code></pre>
<p>This command runs you through a few questions and creates a package.json file for you at the end. This package.json file contains the bare necessities you need to publish your project. (Feel free to skip questions that don’t make sense).</p>
<p>*The final step is to publish your package with the npm publish command:</p>
<pre><code>npm publish
</code></pre>
]]></description><link>https://links.sharezomics.com/post/408</link><guid isPermaLink="true">https://links.sharezomics.com/post/408</guid><dc:creator><![CDATA[Matt]]></dc:creator><pubDate>Fri, 22 Nov 2019 05:47:23 GMT</pubDate></item><item><title><![CDATA[Reply to How to... on Tue, 17 Dec 2019 23:59:57 GMT]]></title><description><![CDATA[<p>How to set permissions in linux with chmod:</p>
<pre><code>chmod 600 {filespec}	You can read and write; the world can't. Good for files.
chmod 700 {filespec}	You can read, write, and execute; the world can't. Good for scripts.
chmod 644 {filespec}	You can read and write; the world can only read. Good for web pages.
chmod 640 {filespec}	You can read and write; group can read, the world can't do anything.Good for group project..
chmod 755 {filespec}	You can read, write, and execute; the world can read and execute. Good for programs you want to share, and your public_html directory.
chmod 750 {filespec}	You can read, write, and execute; the group can read and execute, the world can't do anything. Good for programs you want to share within group.
</code></pre>
]]></description><link>https://links.sharezomics.com/post/410</link><guid isPermaLink="true">https://links.sharezomics.com/post/410</guid><dc:creator><![CDATA[Matt]]></dc:creator><pubDate>Tue, 17 Dec 2019 23:59:57 GMT</pubDate></item><item><title><![CDATA[Reply to How to... on Fri, 03 Jan 2020 09:34:52 GMT]]></title><description><![CDATA[<p>How to install WebODM on Windows 10 home:</p>
<ul>
<li>Download Docker Toolbox and install it as an administrator. (You may need to uninstall VirtualBox first.)</li>
<li>Launch Docker Quickstart Terminal as an administrator. Note down the IP address shown below the whale.</li>
</ul>
<pre><code>
                        ##         .
                  ## ## ##        ==
               ## ## ## ## ##    ===
           /&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;\___/ ===
      ~~~ {~~ ~~~~ ~~~ ~~~~ ~~~ ~ /  ===- ~~~
           \______ o           __/
             \    \         __/
              \____\_______/

docker is configured to use the default machine with IP 192.168.99.100
For help getting started, check out the docs at https://docs.docker.com

</code></pre>
<ul>
<li>Download WebODM with Git and start it:</li>
</ul>
<pre><code>git clone https://github.com/OpenDroneMap/WebODM --config core.autocrlf=input --depth 1
cd WebODM
sh ./webodm.sh start
</code></pre>
<ul>
<li>Navigate to port 8000 of the IP address recorded in the first step:</li>
</ul>
<pre><code>http://192.168.99.100:8000
</code></pre>
<ul>
<li>It is advisable to resize the VM associated with WebODM.</li>
</ul>
<pre><code>cd &quot;C:\Program Files\Oracle\VirtualBox&quot;
./VBoxManage clonemedium disk --format VDI &quot;C:\Users\username\.docker\machine\machines\default\disk.vmdk&quot; &quot;C:\Users\username\.docker\machine\machines\default\disk.vdi&quot;

./VBoxManage modifyhd &quot;C:\Users\username\.docker\machine\machines\default\disk.vdi&quot; --resize 100000
</code></pre>
<p>After resizing you will need to use a GParted VM to resize the partitions.</p>
<ul>
<li>If you want to stop WebODM then use the command:</li>
</ul>
<pre><code>sh ./webodm.sh down
</code></pre>
<ul>
<li>To completely stop WebODM you will have to also stop the VirtualBox VBoxHeadless process using the Windows task manager</li>
</ul>
]]></description><link>https://links.sharezomics.com/post/412</link><guid isPermaLink="true">https://links.sharezomics.com/post/412</guid><dc:creator><![CDATA[Matt]]></dc:creator><pubDate>Fri, 03 Jan 2020 09:34:52 GMT</pubDate></item><item><title><![CDATA[Reply to How to... on Thu, 09 Jan 2020 21:54:57 GMT]]></title><description><![CDATA[<p>How to pipe output from a shell command to Perl to a shell command within a Perl script:</p>
<pre><code>$com='samtools view -h '.$infile;
my $zom='samtools view -bS - &gt; q64converted.bam';
open(SBAM, &quot;$com|&quot;);
open SBOUT, &quot;|$zom&quot;;
while (&lt;SBAM&gt;){
	print SBOUT &quot;$_&quot;;
}
close(SBAM);
close SBOUT;
</code></pre>
]]></description><link>https://links.sharezomics.com/post/414</link><guid isPermaLink="true">https://links.sharezomics.com/post/414</guid><dc:creator><![CDATA[Matt]]></dc:creator><pubDate>Thu, 09 Jan 2020 21:54:57 GMT</pubDate></item><item><title><![CDATA[Reply to How to... on Fri, 10 Jan 2020 02:21:29 GMT]]></title><description><![CDATA[<p>How to find out which pages are visited according to user country in Google Analytics:</p>
<p><img src="/assets/uploads/files/1578622822560-how-to-view-visited-pages-by-country.jpg" alt="how to view visited pages by country.jpg" class="img-responsive img-markdown" /></p>
]]></description><link>https://links.sharezomics.com/post/415</link><guid isPermaLink="true">https://links.sharezomics.com/post/415</guid><dc:creator><![CDATA[Matt]]></dc:creator><pubDate>Fri, 10 Jan 2020 02:21:29 GMT</pubDate></item><item><title><![CDATA[Reply to How to... on Tue, 17 Mar 2020 23:55:29 GMT]]></title><description><![CDATA[<p>How to horizontally split a file view in sublime text editor:</p>
<p>Split the view by using View -&gt; Layout -&gt; Rows: 2. Then select Row 1 and go to File -&gt; New View into File. It will open second tab with the same file. Then you can drag that tab to the Row 2.</p>
]]></description><link>https://links.sharezomics.com/post/417</link><guid isPermaLink="true">https://links.sharezomics.com/post/417</guid><dc:creator><![CDATA[Matt]]></dc:creator><pubDate>Tue, 17 Mar 2020 23:55:29 GMT</pubDate></item><item><title><![CDATA[Reply to How to... on Tue, 29 Jun 2021 03:41:22 GMT]]></title><description><![CDATA[<p>How to push a docker image to Docker Hub:</p>
<ul>
<li>You need to have an account on Docker Hub. In this example the account is named 'ning'.</li>
<li>The image must be built so that the account name is within the image name</li>
</ul>
<p>Eg. for docker command:</p>
<pre><code>docker tag nextflow_docker:202004201512  ning/nextflow_docker:202004201512
</code></pre>
<ul>
<li>For a docker-compose file:</li>
</ul>
<pre><code>version: '3'
services:
  nextflow_docker:
    build: ./nextflow_docker
    image: ning/nextflow_docker:latest
</code></pre>
<ul>
<li>Then you need to push:</li>
</ul>
<pre><code>docker logout
docker login
#login with your username and password (if you are on ubuntu you can ignore password keyring (agree but dont enter a password)
#NB. If you are on ubuntu and get the error message &quot;Error calling StartServiceByName for org.freedesktop.secrets: Timeout was reached&quot; , try the following command &quot;sudo apt remove gnome-keyring golang-docker-credential-helpers&quot;
docker push ning/nextflow_docker:latest
</code></pre>
]]></description><link>https://links.sharezomics.com/post/427</link><guid isPermaLink="true">https://links.sharezomics.com/post/427</guid><dc:creator><![CDATA[Matt]]></dc:creator><pubDate>Tue, 29 Jun 2021 03:41:22 GMT</pubDate></item><item><title><![CDATA[Reply to How to... on Tue, 21 Apr 2020 10:31:10 GMT]]></title><description><![CDATA[<p>How to translate a singularity recipe into a Dockerfile:</p>
<ul>
<li>First install spython:</li>
</ul>
<pre><code>git clone https://www.github.com/singularityhub/singularity-cli.git
cd singularity-cli
python3 setup.py install
</code></pre>
<ul>
<li>Then perform the conversion:</li>
</ul>
<pre><code>spython recipe /input/path/to/singularity/recipe/Singularity /output/path/to/Dockerfile
</code></pre>
]]></description><link>https://links.sharezomics.com/post/428</link><guid isPermaLink="true">https://links.sharezomics.com/post/428</guid><dc:creator><![CDATA[Matt]]></dc:creator><pubDate>Tue, 21 Apr 2020 10:31:10 GMT</pubDate></item><item><title><![CDATA[Reply to How to... on Sun, 03 May 2020 08:33:53 GMT]]></title><description><![CDATA[<p>How to resize the left and right padding in large screens with CSS. (NB. Probably better to use bootstrap with 3 columns instead):</p>
<ul>
<li>In the head section:</li>
</ul>
<pre><code>&lt;head&gt;
  &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt;

  &lt;style&gt;   
    @media screen and (min-width: 768px) {
        body {
            padding-left: 100px;
            padding-right: 100px;
        }
    }
  &lt;/style&gt;

&lt;/head&gt;
</code></pre>
]]></description><link>https://links.sharezomics.com/post/430</link><guid isPermaLink="true">https://links.sharezomics.com/post/430</guid><dc:creator><![CDATA[Matt]]></dc:creator><pubDate>Sun, 03 May 2020 08:33:53 GMT</pubDate></item><item><title><![CDATA[Reply to How to... on Mon, 04 May 2020 08:59:54 GMT]]></title><description><![CDATA[<p>How to horizontally write the address on an envelope in Japan:</p>
<p>〒106-0044東京都港区東麻布1-8-1 ISビル4F GPlusMedia</p>
]]></description><link>https://links.sharezomics.com/post/432</link><guid isPermaLink="true">https://links.sharezomics.com/post/432</guid><dc:creator><![CDATA[Matt]]></dc:creator><pubDate>Mon, 04 May 2020 08:59:54 GMT</pubDate></item><item><title><![CDATA[Reply to How to... on Tue, 19 May 2020 14:21:45 GMT]]></title><description><![CDATA[<p>How to find the meanings of symbols in R:</p>
<pre><code>?&quot;@&quot;
?&quot;&lsqb;&lsqb;&quot;
</code></pre>
]]></description><link>https://links.sharezomics.com/post/436</link><guid isPermaLink="true">https://links.sharezomics.com/post/436</guid><dc:creator><![CDATA[Matt]]></dc:creator><pubDate>Tue, 19 May 2020 14:21:45 GMT</pubDate></item></channel></rss>