Category: status

  • Rename multiple files on Linux If you are…

    http://vedantaiowa.org/?makrosyt=los-angeles-dating-services&005=a8 Rename multiple files on Linux
    If you are lucky to have rename installed on your system, use it.
    Rename is a Perl program and can take Perl regular expression.

    rename 's/^comp/compare/' *pdf

    Or copy the code below.

    http://www.perlmonks.org/?node_id=632437

    
    #!/usr/bin/perl -w
    #
    #  This script was developed by Robin Barker (Robin.Barker@npl.co.uk),
    #  from Larry Wall's original script eg/rename from the perl source.
    #
    #  This script is free software; you can redistribute it and/or modify it
    #  under the same terms as Perl itself.
    #
    # Larry(?)'s RCS header:
    #  RCSfile: rename,v   Revision: 4.1   Date: 92/08/07 17:20:30 
    #
    # $RCSfile: rename,v $$Revision: 1.5 $$Date: 1998/12/18 16:16:31 $
    #
    # $Log: rename,v $
    # Revision 1.5  1998/12/18 16:16:31  rmb1
    # moved to perl/source
    # changed man documentation to POD
    #
    # Revision 1.4  1997/02/27  17:19:26  rmb1
    # corrected usage string
    #
    # Revision 1.3  1997/02/27  16:39:07  rmb1
    # added -v
    #
    # Revision 1.2  1997/02/27  16:15:40  rmb1
    # *** empty log message ***
    #
    # Revision 1.1  1997/02/27  15:48:51  rmb1
    # Initial revision
    #
    
    use strict;
    
    use Getopt::Long;
    Getopt::Long::Configure('bundling');
    
    my ($verbose, $no_act, $force, $op);
    
    die "Usage: rename [-v] [-n] [-f] perlexpr [filenames]\n"
        unless GetOptions(
    	'v|verbose' => \$verbose,
    	'n|no-act'  => \$no_act,
    	'f|force'   => \$force,
        ) and $op = shift;
    
    $verbose++ if $no_act;
    
    if (!@ARGV) {
        print "reading filenames from STDIN\n" if $verbose;
        @ARGV = <STDIN>;
        chop(@ARGV);
    }
    
    for (@ARGV) {
        my $was = $_;
        eval $op;
        die $@ if $@;
        next if $was eq $_; # ignore quietly
        if (-e $_ and !$force)
        {
    	warn  "$was not renamed: $_ already exists\n";
        }
        elsif ($no_act or rename $was, $_)
        {
    	print "$was renamed as $_\n" if $verbose;
        }
        else
        {
    	warn  "Can't rename $was $_: $!\n";
        }
    }
    
    __END__
    
    =head1 NAME
    
    rename - renames multiple files
    
    =head1 SYNOPSIS
    
    B<rename> S<[ B<-v> ]> S<[ B<-n> ]> S<[ B<-f> ]> I<perlexpr> S<[ I<files> ]>
    
    =head1 DESCRIPTION
    
    C<rename>
    renames the filenames supplied according to the rule specified as the
    first argument.
    The I<perlexpr> 
    argument is a Perl expression which is expected to modify the C<$_>
    string in Perl for at least some of the filenames specified.
    If a given filename is not modified by the expression, it will not be
    renamed.
    If no filenames are given on the command line, filenames will be read
    via standard input.
    
    For example, to rename all files matching C<*.bak> to strip the extension,
    you might say
    
    	rename 's/\.bak$//' *.bak
    
    To translate uppercase names to lower, you'd use
    
    	rename 'y/A-Z/a-z/' *
    
    =head1 OPTIONS
    
    =over 8
    
    =item B<-v>, B<--verbose>
    
    Verbose: print names of files successfully renamed.
    
    =item B<-n>, B<--no-act>
    
    No Action: show what files would have been renamed.
    
    =item B<-f>, B<--force>
    
    Force: overwrite existing files.
    
    =back
    
    =head1 ENVIRONMENT
    
    No environment variables are used.
    
    =head1 AUTHOR
    
    Larry Wall
    
    =head1 SEE ALSO
    
    mv(1), perl(1)
    
    =head1 DIAGNOSTICS
    
    If you give an invalid Perl expression you'll get a syntax error.
    
    =head1 BUGS
    
    The original C<rename> did not check for the existence of target filenames,
    so had to be used with care.  I hope I've fixed that (Robin Barker).
    
    =cut
    
    
  • RNA seq normalize read count RPKM= number of…

    RNA-seq; normalize read count

    RPKM=(number of mapping reads)*1000bp*1 million reads/[(length of transcript)*(number of total reads )]

    http://www.clcbio.com/manual/genomics/Definition_RPKM.html
    http://seqanswers.com/forums/showthread.php?t=10657
    http://genomics.isi.edu/rnaseq/framework
    http://www.nature.com/nmeth/journal/v5/n7/pdf/nmeth.1226.pdf

  • Sort files according to the creation time on…

    Sort files according to the creation time on Unix

    Sort by the last saved time

    ls -ltr
    

    Sort by the created time

    ls -lUr
    
  • Save a Perl oneliner to a script perl…

    Save a Perl oneliner to a script.

    perl -MO=Deparse -pe 's/(\d+)/localtime($1)/e'
    

    http://stackoverflow.com/questions/2822525/how-can-i-convert-perl-one-liners-into-complete-scripts

  • matchPWM is now part of Biostrings 2.7.47 in…

    matchPWM() is now part of Biostrings 2.7.47 (in BioC devel, so you need R-2.7).
    
    Load Biostrings:
    
       library(Biostrings)
    
    Suppose 'pwm' contains a Position Weight Matrix, let's say:
    
       pwm <- rbind(A=c( 1,  0, 19, 20, 18,  1, 20,  7),
                    C=c( 1,  0,  1,  0,  1, 18,  0,  2),
                    G=c(17,  0,  0,  0,  1,  0,  0,  3),
                    T=c( 1, 20,  0,  0,  0,  1,  0,  8))
    
    Note that this is just a standard integer matrix with the 4 DNA base letters
    as row names (having these row names is mandatory).
    Some low-level utility functions are available for manipulating this kind of
    matrix:
    
       > maxWeights(pwm)  # the max weight in each column
       [1] 17 20 19 20 18 18 20  8
    
       > maxScore(pwm)  # the max possible score
       [1] 140
    
    Let's match 'pwm' against Human chr1:
    
       library(BSgenome.Hsapiens.UCSC.hg18)
       chr1 <- Hsapiens$chr1
    
    Number of "best" matches:
    
       > countPWM(pwm, chr1, min.score="100%")  # takes about 5 seconds on my system
       [1] 5152
    
    With a lower cut-off value:
    
       m <- matchPWM(pwm, chr1, min.score="90%")
    
    See the 10 first matches ("first" means "smallest chromosome location", NOT "best"
    matches):
    
       > m[1:10]
         Views on a 247249719-letter DNAString subject
       subject: TAACCCTAACCCTAACCCTAACCCTAACCCTAAC...NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN
       views:
            start   end width
        [1] 31931 31938     8 [GTAAACAA]
        [2] 33324 33331     8 [GTAAACAT]
        [3] 38425 38432     8 [GTAAACAG]
        [4] 39177 39184     8 [GTAAACAC]
        [5] 46971 46978     8 [GTAAACAT]
        [6] 49952 49959     8 [GTAAACAT]
        [7] 70381 70388     8 [GTAAACAG]
        [8] 74359 74366     8 [GTAAACAC]
        [9] 90714 90721     8 [GTAAACAT]
       [10] 96544 96551     8 [GTAAACAC]
    
    The speed could be improved, maybe by a factor 2 (or more, for longest PWMs).
    
    Also maybe an additional argument could be added to let the user control how
    the returned matches should be sorted ("left-to-right" or "best-first")?
    
    Unlike MatInspector or the transfac-tool, there is no facility yet to suggest
    individual cut-off values depending on the length of the PWMs.
    
    See '?matchPWM' for more information (e.g. how to search the minus strand of
    the chromosome).
    

    https://stat.ethz.ch/pipermail/bioconductor/2008-April/022029.html

  • Installing Python without root http stackoverflow com questions…

    Installing Python without root.

    http://stackoverflow.com/questions/622744/unable-to-install-python-without-sudo-access

  • Quick and easy submission of R on Sun…

    Quick and easy submission of R on Sun Grid Engine

    Easiest way to submit R jobs

    Here are two scripts and a symlink I created to make it easy as possible to submit R jobs to your Grid:

    qsub-R

    If you normally do something along the lines of:

    user@exec:~$ nohup nice R CMD BATCH toodles.R
    Now all you need to do is:

    user@submit:~$ qsub-R toodles.R
    Your job 3540 (“toodles.R”) has been submitted
    qsub-R is linked to submit-R, a script I wrote. It calls qsub and submits a simple shell wrapper with the R file as an argument. It ends up in the queue and eventually your output arrives in the current directory: toodles.R.o3540

    Download it and install it. You’ll need to make the ‘qsub-R’ symlink to ‘3rd_party/uoa-dos/submit-R’ yourself, although there is one in the package already for lx24-x86: qsub-R.tar (10 KiB, tar)

    http://www.stat.auckland.ac.nz/~kimihia/sun-grid#submitting

  • When Mendeley bibliography duplicates instead of refreshing Check…

    When Mendeley bibliography duplicates instead of refreshing.

    Check whether the following option is set in Word 2007:
    Office button->Word Options->Advanced->General->Confirm file format conversion on open

    http://feedback.mendeley.com/forums/4941-mendeley-feedback/suggestions/1384943-bug-refresh-bibliography-in-word-creates-duplicat

  • Remove the first line in Perl $first line…

    Remove the first line in Perl

    $first_line = <>;
    
    while (<>) {
        do_something();
    }
    
  • Mask repetitive region using BEDtools intersectBed a reads…

    Mask repetitive region using BEDtools.

    intersectBed -a reads.bed -b repeat_region.bed -v