Monday, May 7, 2012

recursively remove broken symlinks in bash

Weblog for atrixnet - recursively remove broken symlinks in bash

Posted by Anonymous (78.32.xx.xx) on Sat 27 Sep 2008 at 01:00
Totally cheating, but after searching for "exist" in the GNU find man page:

find -L . -type l -print0 | xargs -0 --no-run-if-empty rm

With -L (follow symbolic links), -type l matches against the type of the link's target (recursively following links if it's a symlink to a symlink) - unless that target does not exist, in which case it matches against the link.

(The -print0 and -0 options are specific to GNU find and xargs, and allow you to operate on files with bizarre names, e.g. containing newlines, by using the \0 (NUL) character as the line separator. There are only two characters not allowed in Unix filenames - NUL and '/'.)

If that's too subtle, here's a more long-winded solution:

find . | while read -r FILE; do
if ! test -e "$FILE"; then
rm "$FILE"
fi
done

Linux or Unix find and remove files with one find command on fly

Linux or UNIX - Find and remove file syntax

To remove multiple files such as *.jpg or *.sh with one command find, use

find . -name "FILE-TO-FIND"-exec rm -rf {} \;

OR

find . -type f -name "FILE-TO-FIND" -exec rm -f {} \;

Thursday, May 3, 2012

How can i edit some rows in .bam header file? - BioStar

How can i edit some rows in .bam header file? - BioStar


Question: How can i edit some rows in .bam header file?

 
2
 
 

For example i have the following already in the bam header:

@RG ID:110131_SN107_0398_A81DDCABXX_LANE2   PL:ILLUMINA LB:P0007    SM:tumor
@RG ID:110131_SN107_0398_A81DDCABXX_LANE4 PL:ILLUMINA LB:P0007 SM:tumor
@RG ID:110131_SN107_0398_A81DDCABXX_LANE6 PL:ILLUMINA LB:P0007 SM:tumor
@RG ID:110131_SN107_0398_A81DDCABXX_LANE8 PL:ILLUMINA LB:P0007 SM:tumor
@RG ID:110131_SN107_0399_B81CYUABXX_LANE2 PL:ILLUMINA LB:P0007 SM:tumor
@RG ID:110131_SN107_0399_B81CYUABXX_LANE4 PL:ILLUMINA LB:P0007 SM:tumor
@RG ID:110131_SN107_0399_B81CYUABXX_LANE6 PL:ILLUMINA LB:P0007 SM:tumor
@RG ID:110131_SN107_0399_B81CYUABXX_LANE8 PL:ILLUMINA LB:P0007 SM:tumor

i want to make it:

@RG ID:110131_SN107_0398_A81DDCABXX_LANE2   PL:ILLUMINA LB:tumor_P0007  SM:tumor
@RG ID:110131_SN107_0398_A81DDCABXX_LANE4 PL:ILLUMINA LB:tumor_P0007 SM:tumor
@RG ID:110131_SN107_0398_A81DDCABXX_LANE6 PL:ILLUMINA LB:tumor_P0007 SM:tumor
@RG ID:110131_SN107_0398_A81DDCABXX_LANE8 PL:ILLUMINA LB:tumor_P0007 SM:tumor
@RG ID:110131_SN107_0399_B81CYUABXX_LANE2 PL:ILLUMINA LB:tumor_P0007 SM:tumor
@RG ID:110131_SN107_0399_B81CYUABXX_LANE4 PL:ILLUMINA LB:tumor_P0007 SM:tumor
@RG ID:110131_SN107_0399_B81CYUABXX_LANE6 PL:ILLUMINA LB:tumor_P0007 SM:tumor
@RG ID:110131_SN107_0399_B81CYUABXX_LANE8 PL:ILLUMINA LB:tumor_P0007 SM:tumor

Thanks.

 
 

1 answer



 
12
 
 
 

samtools view -H mybamfile.bam | sed -e 's/LB:/LB:tumor_/' | samtools reheader - mybamfile.bam > mybamfile.reheadered.bam

Wednesday, February 8, 2012

scp as a background process

scp as a background process « Kunal Bharati
scp as a background process

To execute any linux command in background we use nohup as follows:

1 $ nohup SOME_COMMAND &

But the problem with scp command is that it prompts for the password (if password authentication is used). So to make scp execute as a background process do this:

1 $ nohup scp file_to_copy user@server:/path/to/copy/the/file > nohup.out 2>&1

Then press ctrl + z which will temporarily suspend the command, then enter the command:

1 $ bg

This will start executing the command in backgroud
Advertisement
Share this:

Share

Like this:
Like
Be the first to like this post.

Tags: Linux, tips n tricks


Monday, November 28, 2011

http://lausanne.isb-sib.ch/~sengstag/bioc_mirror.html

Setting up a local BioConductor mirror

Conventions:

BIOCDISK = The path to a big disk that will contain the BioConductor files
YOURSERVER = The name of the machine that will serve the files

Setting up the mirror

The present instructions are for BioConductor 1.9 which is to
be used in conjunction with R 2.4.

Note: Given that the BioConductor directory structure changed
by version 1.8, these instructions should not be expected to work
with earlier versions.

Preparing the distribution directory

Setup the copy of the official repository:

 rsync -rtlv bioconductor.org::1.9 BIOCDISK/bioconductor/packages/1.9

The rsync command should be on a crontab to maintain the mirror in sync.

Download original installation scripts:

 cd BIOCDISK/bioconductor/
wget http://www.bioconductor.org/getBioC.R
wget http://www.bioconductor.org/biocLite.R

Download core install script for R version corresponding to BioC version:

 mkdir -p BIOCDISK/bioconductor/installScripts/2.4
cd BIOCDISK/bioconductor/installScripts/2.4
wget http://bioconductor.org/installScripts/2.4/biocinstall.R

Adapt the hardcoded paths in scripts to point to the new server:

 cd BIOCDISK/bioconductor/
foreach f (getBioC.R biocLite.R installScripts/2.4/biocinstall.R)
cp $f $f.save
sed -e 's/http:\/\/[w.]*bioconductor.org/http:\/\/YOURSERVER\/bioconductor/g' $f.save > $f
end

Configuring web server (debian machine)

Create the file /etc/apache2/conf.d/bioconductor.conf:

 Alias /bioconductor BIOCDISK/bioconductor
<Directory "BIOCDISK/bioconductor">
EnableSendfile Off # In case there is no sendfile() support (happens with NFS)
Options +Indexes
Order deny,allow
Allow from all
</Directory>

Then reload http configuration with:

 /etc/init.d/apache2 reload

Use a browser to check that the mirror is visible: http://YOURSERVER/bioconductor

Using the mirror

The BioConductor mirror is used in the same way as the original BioConductor
repository, the only difference being that wherever "http://www.bioconductor.org/"
or "http://bioconductor.org/" occurs in the documentation, these strings must be
replaced by "http://YOURSERVER/bioconductor/".

Base install, light:

 source("http://YOURSERVER/bioconductor/biocLite.R")
biocLite()

Base install, heavier:

 source("http://YOURSERVER/bioconductor/getBioC.R")
getBioC()

Installation of extra packages:

 source("http://YOURSERVER/bioconductor/biocLite.R")
biocLite(c("pkg1", "pkg2"))

Individual files on the mirror can be accessed from http://YOURSERVER/bioconductor

Version 1.0, Thierry Sengstag, October 26, 2006

Saturday, July 16, 2011

scp as a background process « Kunal Bharati

scp as a background process « Kunal Bharati

kunal@localhost$

Home
About me

scp as a background process
October 20, 2010
tags: Linux, tips n tricks
by kunalbharati

To execute any linux command in background we use nohup as follows:
1 $ nohup SOME_COMMAND &

But the problem with scp command is that it prompts for the password (if password authentication is used). So to make scp execute as a background process do this:
1 $ nohup scp file_to_copy user@server:/path/to/copy/the/file > nohup.out 2>&1

Then press ctrl + z which will temporarily suspend the command, then enter the command:
1 $ bg

This will start executing the command in backgroud


scp as a background process « Kunal Bharati

scp as a background process « Kunal Bharati

kunal@localhost$

Home
About me

scp as a background process
October 20, 2010
tags: Linux, tips n tricks
by kunalbharati

To execute any linux command in background we use nohup as follows:
1 $ nohup SOME_COMMAND &

But the problem with scp command is that it prompts for the password (if password authentication is used). So to make scp execute as a background process do this:
1 $ nohup scp file_to_copy user@server:/path/to/copy/the/file > nohup.out 2>&1

Then press ctrl + z which will temporarily suspend the command, then enter the command:
1 $ bg

This will start executing the command in backgroud


Monday, April 18, 2011

How to install Apache, PHP and MySQL on Linux: Part 2

How to install Apache, PHP and MySQL on Linux: Part 2 | laffers.net

Setup access privileges

Don’t forget to setup Apache access privileges to your www directories:

1chown -R apache2:www <em>/foo/path_to_your_www_documents_root</em>
2chmod -R 750 <em>/foo/path_to_your_www_documents_root</em>

“apache2″ and “www” are the user and user group I have previously created (see Prerequisites)

Start and stop apache server

After everything is set up, start Apache:

1/usr/local/apache2/bin/apachectl start

Similarly, if you wish to stop Apache, type:

1/usr/local/apache2/bin/apachectl stop

Automatic startup

It’s a good idea to let your Apache server start automatically after each system reboot. To setup Apache automatic startup, do:

1cp /usr/local/apache2/bin/apachectl /etc/init.d
2chmod 755 /etc/init.d/apachectl
3chkconfig --add apachectl
4chkconfig --level 35 apachectl on

Sunday, April 17, 2011

Subversion + Apache Installation and Repository Migration HOWTO - Matt Woodward's posterous

Subversion + Apache Installation and Repository Migration HOWTO - Matt Woodward's posterous

 

Create Basic HTTP Passwords

Next we'll create the SVN password file referenced in the dav_svn.conf file above.

Type the following to navigate to the /etc/apache2 directory and create the .passwd file and add the first user to it.

 

  1. cd /etc/apache2  
  2. sudo htpasswd -cm dav_svn.passwd YOUR_USER_NAME  

 

Installing a Subversion server on Leopard

 

Sonzea

LoadModule dav_svn_module libexec/apache2/mod_dav_svn.so LoadModule authz_svn_module libexec/apache2/mod_authz_svn.so <Location /repo> DAV svn SVNPath /usr/local/repo </Location>

Move a Subversion Repository from One Remote Server to Another

Using Subversion on Mac OS X for version control

 

Move a Subversion Repository from One Remote Server to Another | Minor Addition

 

Move a Subversion Repository from One Remote Server to Another | Minor Addition

Move a Subversion Repository from One Remote Server to Another

Wednesday, April 6, 2011

Wednesday, February 2, 2011

Advanced SGE Commands

Ranger Virtual Workshop
Advanced SGE Commands

At this point, you should have all of the basic information on tools that you need to submit and query jobs on Ranger. In this final section on SGE, we'll go through a few more commands that you may find useful as you go along. At the bottom of the page, you'll find included a table that also provides a conversion chart for SGE commands to other batch processors.
qhold/qrls

Once a job has been submitted, there are times when you may want to suspend or stop a job outright. Perhaps the job depends on data that hasn't finished uploading yet, whatever the reason, SGE provides you with the qhold tool for that.

qhold 28780

Specifically, when you issue a hold on a job you are setting a user hold on the job. There are also system and operator holds, but you'll only be setting user holds, which you implicitely set. To explicitely set a user hold, specify:

login3% qhold -h u 28780
job-ID prior name user state submit/start at queue slots ja-task-ID
-----------------------------------------------------------------------------------------------------------------
28780 0.00000 testJob username hqw 02/25/2008 07:56:57

We can see that the state has changed from the queued state (qw) to a held state (hqw). At this point, we have two options, either we are ready for the job to continue, or we want delete the job. For these two sitations, we use the qrls (release) and qdel commands.

login3% qrls -h u 28780
modified hold of job 28780
login3% qdel 28785
userName has deleted job 28785

There are situations where qdel won't work, and won't delete the job. For instance, if a node lit on fire while running your job, you won't be able to delete that job. qdel will send a signal to the daemon (ge_execd) to delete the job, but won't get a response. In this case, the only way to delete the job will be to add the -f (force) option to qdel. This tells the scheduler to not wait for confirmation from the node, you should only use this option when you have to!

Tuesday, October 26, 2010

Bioinformatics software and tools

bamtools:
API and toolkit for reading, writing, and manipulating BAM (genome alignment) files
http://github.com/pezmaster31/bamtools/

bedtools:
The BEDTools utilities allow one to address common genomics tasks such as finding feature overlaps and computing coverage.
http://code.google.com/p/bedtools/

MAC OS X software and tools

GIT:
Git is distributed version control system focused on speed, effectivity and real-world usability on large projects.
http://git-scm.com/