[Patchwork-commits] r40 - in pkg/patchwork: R inst/python
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Dec 7 11:49:09 CET 2011
Author: sebastian_d
Date: 2011-12-07 11:49:08 +0100 (Wed, 07 Dec 2011)
New Revision: 40
Added:
pkg/patchwork/inst/python/Check.py
Modified:
pkg/patchwork/R/patchwork.CNA.r
pkg/patchwork/R/patchwork.alleledata.r
pkg/patchwork/R/patchwork.readChroms.r
pkg/patchwork/inst/python/Pysamloader.py
Log:
Fixed installation of pysam to users system if needed. Also added a check for .python folder to be deleted if it already existed. Also changed data file handling in readChroms
Modified: pkg/patchwork/R/patchwork.CNA.r
===================================================================
--- pkg/patchwork/R/patchwork.CNA.r 2011-12-06 14:37:39 UTC (rev 39)
+++ pkg/patchwork/R/patchwork.CNA.r 2011-12-07 10:49:08 UTC (rev 40)
@@ -1,6 +1,7 @@
patchwork.CNA <- function(BamFile,Pileup,reference,Alpha=0.0001,SD=1)
{
-
+ #library(patchwork)
+ #patchwork.CNA("cancer.bam","pile.up",reference="illumina")
#Load DNAcopy
#library(DNAcopy)
#Load data included in package
@@ -16,7 +17,7 @@
#If it wasnt created, create it using the perl script pile2alleles.pl
#which is included in the package. Creates pile.alleles in whichever folder
#you are running R from. (getwd())
- if(length(alf) == 1)
+ if(length(alf) == 0)
{
cat("Initiating Allele Data Generation \n")
alf = patchwork.alleledata(Pileup)
Modified: pkg/patchwork/R/patchwork.alleledata.r
===================================================================
--- pkg/patchwork/R/patchwork.alleledata.r 2011-12-06 14:37:39 UTC (rev 39)
+++ pkg/patchwork/R/patchwork.alleledata.r 2011-12-07 10:49:08 UTC (rev 40)
@@ -6,8 +6,17 @@
#load(paste(packagepath,"/data/commonSnps132.RData",sep=""))
data(commonSnps132,package="patchworkData")
- #load(paste(packagepath,"/data/ideogram.RData",sep=""))
- #load(paste(packagepath,"/data/normaldata.RData",sep=""))
+
+ #if .perl folder exists, delete it.
+ #test = getwd()
+ #try( setwd(".perl"),silent=TRUE)
+ #if(getwd() == paste(test,"/.perl",sep=""))
+ # {
+ # setwd("..")
+ # system("rm -r .perl")
+ # }
+
+
system(paste("cp -r ",packagepath,"/perl .perl",sep=""))
system(paste("cat ",Pileup," | perl .perl/pile2alleles.pl > ",getwd(),"/pile.alleles",sep=""))
system("rm -r .perl")
Modified: pkg/patchwork/R/patchwork.readChroms.r
===================================================================
--- pkg/patchwork/R/patchwork.readChroms.r 2011-12-06 14:37:39 UTC (rev 39)
+++ pkg/patchwork/R/patchwork.readChroms.r 2011-12-07 10:49:08 UTC (rev 40)
@@ -3,13 +3,42 @@
## Read chromosomes:
# Ideogram data downloaded from UCSC table browser.
+ #library(patchwork)
+ #patchwork.CNA("cancer.bam","pile.up",reference="illumina")
+
#Load data included in package
packagepath = system.file(package="patchwork")
- #load(paste(packagepath,"/data/commonSnps132.RData",sep=""))
- #load(paste(packagepath,"/data/ideogram.RData",sep=""))
- #load(paste(packagepath,"/data/normaldata.RData",sep=""))
+ datapath = system.file(package="patchworkData")
+
+
+
+ #if .python folder exists, delete it.
+ test = getwd()
+ try( setwd(".python"),silent=TRUE)
+ if(getwd() == paste(test,"/.python",sep=""))
+ {
+ setwd("..")
+ system("rm -r .python")
+ }
+
+
+ #copy python folder
system(paste("cp -r ",packagepath,"/python .python",sep=""))
+
+ #if .python folder exists, delete it.
+
+ #If import pysam doesnt work, ie pysam isnt installed yet, we install pysam.
+ if (system(paste("python ",getwd(),"/.python/Check.py",sep=""),intern=T) == "Pysam Not Available")
+ {
+ setwd(".python")
+ # build pysam
+ system("python setup.py build",invisible=F)
+ # install pysam to site.USER_BASE
+ system("python setup.py install --user",invisible=F)
+ setwd("..")
+ }
+
readlength=80 # this is currently hard coded and may be adjusted.
seglength=200 # (do not change)
data=NULL
@@ -24,8 +53,7 @@
# Load the newly created position file
unix = read.csv(".Tmp_chr_pos",sep='',header=F)$V1 + readlength/2
tmp = paste(c,".mark",sep="")
- data(tmp,package="patchworkData")
- #load(paste(packagepath,"/data/",c,'.mark.RData',sep=''))
+ load(paste(datapath,"/data/",c,".mark.RData",sep=""))
xpos=gc[,1]
xgc=gc[,2]
xgck=gc[,3]
Added: pkg/patchwork/inst/python/Check.py
===================================================================
--- pkg/patchwork/inst/python/Check.py (rev 0)
+++ pkg/patchwork/inst/python/Check.py 2011-12-07 10:49:08 UTC (rev 40)
@@ -0,0 +1,11 @@
+import sys
+import os
+
+try:
+ import pysam
+ print "X"
+ sys.exit()
+except:
+ #It didnt work.
+ print "Pysam Not Available"
+ sys.exit()
Modified: pkg/patchwork/inst/python/Pysamloader.py
===================================================================
--- pkg/patchwork/inst/python/Pysamloader.py 2011-12-06 14:37:39 UTC (rev 39)
+++ pkg/patchwork/inst/python/Pysamloader.py 2011-12-07 10:49:08 UTC (rev 40)
@@ -6,13 +6,21 @@
# soemthing like try(import pysam)
# if nono install it.
-try:
- import pysam
-except:
- p = "export PYTHONPATH=$PYTHONPATH:%s" % os.path.dirname(os.path.abspath(sys.argv[0]))
- os.system(p)
- import pysam
+ #library(patchwork)
+ #patchwork.CNA("cancer.bam","pile.up",reference="illumina")
+#try:
+# import pysam
+#except:
+ #p = "export PYTHONPATH=$PYTHONPATH:%s" % os.path.dirname(os.path.abspath(sys.argv[0]))
+ #os.system(p)
+# a = "python %s/.python/setup.py build" % os.path.dirname(os.path.abspath(sys.argv[0]))
+# os.system(a)
+# b = "python %s/python/setup.py install" % os.path.dirname(os.path.abspath(sys.argv[0]))
+# print b
+# os.system(b)
+import pysam
+
try:
infile = pysam.Samfile(sys.argv[1],"rb")
except IOError,eStr:
More information about the Patchwork-commits
mailing list