Mercurial > repos > george-weingart > maaslin
comparison src/CreateReadConfigFile.R @ 8:e9677425c6c3 default tip
Updated the structure of the libraries
author | george.weingart@gmail.com |
---|---|
date | Mon, 09 Feb 2015 12:17:40 -0500 |
parents | e0b5980139d9 |
children |
comparison
equal
deleted
inserted
replaced
7:c72e14eabb08 | 8:e9677425c6c3 |
---|---|
1 #!/usr/bin/env Rscript | |
2 ##################################################################################### | |
3 #Copyright (C) <2012> | |
4 # | |
5 #Permission is hereby granted, free of charge, to any person obtaining a copy of | |
6 #this software and associated documentation files (the "Software"), to deal in the | |
7 #Software without restriction, including without limitation the rights to use, copy, | |
8 #modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, | |
9 #and to permit persons to whom the Software is furnished to do so, subject to | |
10 #the following conditions: | |
11 # | |
12 #The above copyright notice and this permission notice shall be included in all copies | |
13 #or substantial portions of the Software. | |
14 # | |
15 #THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, | |
16 #INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A | |
17 #PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | |
18 #HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | |
19 #OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | |
20 #SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |
21 # | |
22 # This file is a component of the MaAsLin (Multivariate Associations Using Linear Models), | |
23 # authored by the Huttenhower lab at the Harvard School of Public Health | |
24 # (contact Timothy Tickle, ttickle@hsph.harvard.edu). | |
25 ##################################################################################### | |
26 | |
27 inlinedocs <- function( | |
28 ##author<< Curtis Huttenhower <chuttenh@hsph.harvard.edu> and Timothy Tickle <ttickle@hsph.harvard.edu> | |
29 ##description<< Allows read config files to be created. | |
30 ) { return( pArgs ) } | |
31 | |
32 ### Logging class | |
33 suppressMessages(library( logging, warn.conflicts=FALSE, quietly=TRUE, verbose=FALSE)) | |
34 ### Class for commandline argument processing | |
35 suppressMessages(library( optparse, warn.conflicts=FALSE, quietly=TRUE, verbose=FALSE)) | |
36 | |
37 ### Source the IO.R for the script | |
38 source(file.path("src","lib","IO.R")) | |
39 source(file.path("src","lib","Constants.R")) | |
40 | |
41 ### Create command line argument parser | |
42 ### The TSV (tab seperated value (column major, samples are rows) file that will be read in | |
43 ### The column that is the last metadata name | |
44 ### The read.config file that will be used to read in the TSV file | |
45 pArgs <- OptionParser( usage = "%prog [optional] <strOutputRC> <strMatrixName>" ) | |
46 # Settings for Read config | |
47 ## row indices | |
48 pArgs <- add_option( pArgs, c("-r", "--rows"), type="character", action="store", dest="strRows", default=NA, metavar="row_indices", help="Rows to read by index starting with 1.") | |
49 ## column indices | |
50 pArgs <- add_option( pArgs, c("-c", "--columns"), type="character", action="store", dest="strColumns", default=NA, metavar="column_indices", help="Columns to read in by index starting with 1.") | |
51 ## delimiter | |
52 pArgs <- add_option( pArgs, c("-d", "--delimiter"), type="character", action="store", dest="charDelimiter", default="\t", metavar="delimiter", help="Delimiter to read the matrix.") | |
53 ## append to current file | |
54 pArgs <- add_option( pArgs, c("-a", "--append"), type="logical", action="store_true", dest="fAppend", default=FALSE, metavar="append", help="Append to existing data. Default no append.") | |
55 ### Parse arguments | |
56 lsArgs <- parse_args( pArgs, positional_arguments = TRUE ) | |
57 | |
58 #Get positional arguments | |
59 if( !(length( lsArgs$args ) == 2) ) { stop( print_help( pArgs ) ) } | |
60 | |
61 ### Write to file the read config script | |
62 funcWriteMatrixToReadConfigFile(strConfigureFileName=lsArgs$args[1], strMatrixName=lsArgs$args[2], strRowIndices=lsArgs$options$strRows, | |
63 strColIndices=lsArgs$options$strColumns,acharDelimiter=lsArgs$options$charDelimiter,fAppend=lsArgs$options$fAppend) |