Révision c68acc42

b/README
1
***************************************
2
Readme / Documentation for `cachecache`
3
***************************************
4

  
5
`cachecache` offers Python API and R package allowing to perform 
6
direct qtl detection from raw sequence reads of yeast populations under selection.
7

  
8
License
9
=======
10

  
11
Copyright CNRS 2012-2013                                                 
12
                                                                          
13
- Florent CHUFFART                                                         
14
- Gael YVERT                                                               
15
                                                                          
16
This software is a computer program which purpose is to perform direct qtl 
17
detection from raw sequence reads of yeast populations under selection.
18
                                                                          
19
The Software is provided "as is" without warranty of any kind, either express or 
20
implied, including without limitation any implied warranties of condition, 
21
uninterrupted use, merchantability, fitness for a particular purpose, or 
22
non-infringement. You use this software at your own risk.
23
								                                                           
24
This software is governed by the CeCILL license under French law and     
25
abiding by the rules of distribution of free software.  You can  use,    
26
modify and/ or redistribute the software under the terms of the CeCILL   
27
license as circulated by CEA, CNRS and INRIA at the following URL        
28
"http://www.cecill.info".                                                
29
                                                                          
30
As a counterpart to the access to the source code and  rights to copy,   
31
modify and redistribute granted by the license, users are provided only  
32
with a limited warranty  and the software's author,  the holder of the   
33
economic rights,  and the successive licensors  have only  limited       
34
liability.                                                               
35
                                                                          
36
In this respect, the user's attention is drawn to the risks associated   
37
with loading,  using,  modifying and/or developing or reproducing the    
38
software by the user in light of its specific status of free software,   
39
that may mean  that it is complicated to manipulate,  and  that  also    
40
therefore means  that it is reserved for developers  and  experienced    
41
professionals having in-depth computer knowledge. Users are therefore    
42
encouraged to load and test the software's suitability as regards their  
43
requirements in conditions enabling the security of their systems and/or 
44
data to be ensured and,  more generally, to use and operate it in the    
45
same conditions as regards security.                                     
46
                                                                          
47
The fact that you are presently reading this means that you have had     
48
knowledge of the CeCILL license and that you accept its terms.           
49

  
50
Installation Instructions
51
=========================
52

  
53
Links
54
-----
55

  
56
`cachecache` home page: https://forge.cbp.ens-lyon.fr/redmine/projects/cachecache
b/src/DESCRIPTION
1
Package: cachecache
2
Maintainer: Florent Chuffart <florent.chuffart@ens-lyon.fr>
3
Author: Florent Chuffart
4
Version: 0.2
5
License: CeCILL 
6
Title: cachecache
7
Depends: 
8
Description: cachecache is an R package allowing to reduce disk access by managing a cache. Data on the disk is identified by a path that is also an index in the cache (an R list). this index provide an access to the same data in RAM space. cachecache is used to compute NGS data in the SiGHT project context (ERC-StG2011-281359). For more information on how to use bot, have a look on the examples of the help ?cahecache::get_content.
9
URL: http://forge.cbp.ens-lyon.fr/redmine/projects/cachecache http://www.ens-lyon.fr/LBMC/gisv/index.php/en/protocols/bioinformatics  http://www.ens-lyon.fr/LBMC/gisv
10

  
11
 
12

  
13
  
b/src/NAMESPACE
1
export(get_content)
b/src/R/cachecache.R
1
get_content = structure( function(## Get content from cached 
2
### Access to the cached content of a file via the global variable CACHE_CACHE. Load content in CACHE_CACHE if needed.
3
filename, ##<< The path to the file that contain dataset.
4
class=NULL, ##<< The class of dataset.
5
... ##<< Parameters that will be passed to my_read
6
) {
7
  if (inherits(try(CACHE_CACHE,TRUE), "try-error") || is.null(CACHE_CACHE)) {
8
    CACHE_CACHE <<- list()
9
  }
10
  obj = list(filename=filename)
11
  class(obj) = class
12
  if (is.null(CACHE_CACHE[[obj$filename]])) {
13
    print(paste("Loading file ",obj$filename, sep=""))
14
		tmp_content = my_read(obj, ...)
15
    print("affect it...")
16
    CACHE_CACHE[[obj$filename]] <<- tmp_content
17
    print("done.")
18
  }  
19
  return(CACHE_CACHE[[obj$filename]])
20
### Returns the cached content of the current object. 
21
}, ex=function(){
22
	# Create a dataframe
23
	df = data.frame(list(key1 = "value1", key2 = "value2"), stringsAsFactors=FALSE)
24
	df = rbind(df, list(key1 = "value1'", key2 = "value3'"))
25
	# Dump it into tmp file
26
	write.table(df, file="/tmp/tmp.dump.table.tmp")
27
	# Load it into cache using feature.
28
	# First time it will be load into cache
29
	print(get_content("/tmp/tmp.dump.table.tmp", "table", stringsAsFactors=FALSE))
30
	# Second time not
31
	print(get_content("/tmp/tmp.dump.table.tmp", "table", stringsAsFactors=FALSE))
32
	
33
})
34
	
35
my_read = function(
36
### Abstract my_read function.	
37
	obj, ...) {
38
  UseMethod("my_read", obj)
39
}
40
	
41
my_read.default = function(
42
### Default my_read function.	
43
	obj, ...){
44
  stop(paste("ERROR, my_read is not defined for any Objects (file ", obj$filename," )", sep=""))			
45
}
46

  
47
my_read.table = function(
48
### my_read function for table files.	
49
	obj, ...){
50
	if (rev(unlist(strsplit(obj$filename, ".", fixed=TRUE)))[1] == "gz") {
51
	  return(read.table(file=gzfile(obj$filename), ...))			
52
	} else { 
53
	  return(read.table(file=obj$filename, ...))
54
	}
55
}	
56

  
57
my_read.cvs = function(
58
### my_read function for cvs files.	
59
	obj, ...){
60
  return(read.csv(file=obj$filename, ...))
61
}	

Formats disponibles : Unified diff