0
|
1 <html>
|
|
2 <head>
|
|
3 <title>MayaChemTools:Documentation:ExtractFromTextFiles.pl</title>
|
|
4 <meta http-equiv="content-type" content="text/html;charset=utf-8">
|
|
5 <link rel="stylesheet" type="text/css" href="../../css/MayaChemTools.css">
|
|
6 </head>
|
|
7 <body leftmargin="20" rightmargin="20" topmargin="10" bottommargin="10">
|
|
8 <br/>
|
|
9 <center>
|
|
10 <a href="http://www.mayachemtools.org" title="MayaChemTools Home"><img src="../../images/MayaChemToolsLogo.gif" border="0" alt="MayaChemTools"></a>
|
|
11 </center>
|
|
12 <br/>
|
|
13 <div class="DocNav">
|
|
14 <table width="100%" border=0 cellpadding=0 cellspacing=2>
|
|
15 <tr align="left" valign="top"><td width="33%" align="left"><a href="./ExtractFromSequenceFiles.html" title="ExtractFromSequenceFiles.html">Previous</a> <a href="./index.html" title="Table of Contents">TOC</a> <a href="./FilterSDFiles.html" title="FilterSDFiles.html">Next</a></td><td width="34%" align="middle"><strong>ExtractFromTextFiles.pl</strong></td><td width="33%" align="right"><a href="././code/ExtractFromTextFiles.html" title="View source code">Code</a> | <a href="./../pdf/ExtractFromTextFiles.pdf" title="PDF US Letter Size">PDF</a> | <a href="./../pdfgreen/ExtractFromTextFiles.pdf" title="PDF US Letter Size with narrow margins: www.changethemargins.com">PDFGreen</a> | <a href="./../pdfa4/ExtractFromTextFiles.pdf" title="PDF A4 Size">PDFA4</a> | <a href="./../pdfa4green/ExtractFromTextFiles.pdf" title="PDF A4 Size with narrow margins: www.changethemargins.com">PDFA4Green</a></td></tr>
|
|
16 </table>
|
|
17 </div>
|
|
18 <p>
|
|
19 </p>
|
|
20 <h2>NAME</h2>
|
|
21 <p>ExtractFromTextFiles.pl - Extract specific data from TextFile(s)</p>
|
|
22 <p>
|
|
23 </p>
|
|
24 <h2>SYNOPSIS</h2>
|
|
25 <p>ExtractFromTextFiles.pl TextFile(s)...</p>
|
|
26 <p>ExtractFromTextFiles.pl [<strong>-c, --colmode</strong> colnum | collabel] [<strong>--categorycol </strong> number | string]
|
|
27 [<strong>--columns</strong> "colnum,[colnum]..." | "collabel,[collabel]..."] [<strong>-h, --help</strong>]
|
|
28 [<strong>--indelim</strong> <em>comma | semicolon</em>] [<strong>-m, --mode </strong> <em>columns | rows | categories</em>]
|
|
29 [<strong>-o, --overwrite</strong>] [<strong>--outdelim</strong> <em>comma | tab | semicolon</em>] [<strong>-q, --quote</strong> <em>yes | no</em>]
|
|
30 [<strong>--rows</strong> "colid,value,criteria..." | "colid,value..." | "colid,mincolvalue,maxcolvalue" | "rownum,rownum,..." | colid | "minrownum,maxrownum"]
|
|
31 [ <strong>--rowsmode</strong> rowsbycolvalue | rowsbycolvaluelist | rowsbycolvaluerange | rowbymincolvalue | rowbymaxcolvalue | rownums | rownumrange]
|
|
32 [<strong>-r, --root</strong> <em>rootname</em>] [<strong>-w, --workingdir</strong> <em>dirname</em>] TextFile(s)...</p>
|
|
33 <p>
|
|
34 </p>
|
|
35 <h2>DESCRIPTION</h2>
|
|
36 <p>Extract column(s)/row(s) data from <em>TextFile(s)</em> identified by column numbers or labels. Or categorize
|
|
37 data using a specified column category. During categorization, a summary text file is
|
|
38 generated containing category name and count; an additional text file, containing data for
|
|
39 for each category, is also generated. The file names are separated by space. The
|
|
40 valid file extensions are <em>.csv</em> and <em>.tsv</em> for comma/semicolon and tab delimited
|
|
41 text files respectively. All other file names are ignored. All the text files in a
|
|
42 current directory can be specified by <em>*.csv</em>, <em>*.tsv</em>, or the current directory
|
|
43 name. The <strong>--indelim</strong> option determines the format of <em>TextFile(s)</em>. Any file
|
|
44 which doesn't correspond to the format indicated by <strong>--indelim</strong> option is ignored.</p>
|
|
45 <p>
|
|
46 </p>
|
|
47 <h2>OPTIONS</h2>
|
|
48 <dl>
|
|
49 <dt><strong><strong>-c, --colmode</strong> <em>colnum | collabel</em></strong></dt>
|
|
50 <dd>
|
|
51 <p>Specify how columns are identified in <em>TextFile(s)</em>: using column number or column
|
|
52 label. Possible values: <em>colnum or collabel</em>. Default value: <em>colnum</em>.</p>
|
|
53 </dd>
|
|
54 <dt><strong><strong>--categorycol </strong> <em>number | string</em></strong></dt>
|
|
55 <dd>
|
|
56 <p>Column used to categorize data. Default value: First column.</p>
|
|
57 <p>For <em>colnum</em> value of <strong>-c, --colmode</strong> option, input value is a column number.
|
|
58 Example: <em>1</em>.</p>
|
|
59 <p>For <em>collabel</em> value of <strong>-c, --colmode</strong> option, input value is a column label.
|
|
60 Example: <em>Mol_ID</em>.</p>
|
|
61 </dd>
|
|
62 <dt><strong><strong>--columns</strong> <em>"colnum,[colnum]..." | "collabel,[collabel]..."</em></strong></dt>
|
|
63 <dd>
|
|
64 <p>List of comma delimited columns to extract. Default value: First column.</p>
|
|
65 <p>For <em>colnum</em> value of <strong>-c, --colmode</strong> option, input values format is:
|
|
66 <em>colnum,colnum,...</em>. Example: <em>1,3,5</em></p>
|
|
67 <p>For <em>collabel</em> value of <strong>-c, --colmode</strong> option, input values format is:
|
|
68 <em>collabel,collabel,..</em>. Example: <em>Mol_ID,MolWeight</em></p>
|
|
69 </dd>
|
|
70 <dt><strong><strong>-h, --help</strong></strong></dt>
|
|
71 <dd>
|
|
72 <p>Print this help message.</p>
|
|
73 </dd>
|
|
74 <dt><strong><strong>--indelim</strong> <em>comma | semicolon</em></strong></dt>
|
|
75 <dd>
|
|
76 <p>Input delimiter for CSV <em>TextFile(s)</em>. Possible values: <em>comma or semicolon</em>.
|
|
77 Default value: <em>comma</em>. For TSV files, this option is ignored and <em>tab</em> is used as a
|
|
78 delimiter.</p>
|
|
79 </dd>
|
|
80 <dt><strong><strong>-m, --mode </strong> <em>columns | rows | categories</em></strong></dt>
|
|
81 <dd>
|
|
82 <p>Specify what to extract from <em>TextFile(s)</em>. Possible values: <em>columns, rows,
|
|
83 or categories</em>. Default value: <em>columns</em>.</p>
|
|
84 <p>For <em>columns</em> mode, data for appropriate columns specified by <strong>--columns</strong> option
|
|
85 is extracted from <em>TextFile(s)</em> and placed into new text files.</p>
|
|
86 <p>For <em>rows</em> mode, appropriate rows specified in conjuction with <strong>--rowsmode</strong> and
|
|
87 <strong>rows</strong> options are extracted from <em>TextFile(s)</em> and placed into new text files.</p>
|
|
88 <p>For <em>categories</em> mode, coulmn specified by <strong>--categorycol</strong> is
|
|
89 used to categorize data, and a summary text file is generated
|
|
90 containing category name and count; an additional text file, containing data for
|
|
91 for each category, is also generated.</p>
|
|
92 </dd>
|
|
93 <dt><strong><strong>-o, --overwrite</strong></strong></dt>
|
|
94 <dd>
|
|
95 <p>Overwrite existing files.</p>
|
|
96 </dd>
|
|
97 <dt><strong><strong>--outdelim</strong> <em>comma | tab | semicolon</em>.</strong></dt>
|
|
98 <dd>
|
|
99 <p>Output text file delimiter. Possible values: <em>comma, tab, or semicolon</em>.
|
|
100 Default value: <em>comma</em></p>
|
|
101 </dd>
|
|
102 <dt><strong><strong>-q, --quote</strong> <em>yes | no</em></strong></dt>
|
|
103 <dd>
|
|
104 <p>Put quotes around column values in output text file. Possible values: <em>yes or
|
|
105 no</em>. Default value: <em>yes</em>.</p>
|
|
106 </dd>
|
|
107 <dt><strong><strong>-r, --root</strong> <em>rootname</em></strong></dt>
|
|
108 <dd>
|
|
109 <p>New file name is generated using the root: <Root>.<Ext>. Default for new file
|
|
110 names: <TextFile>CategoriesSummary.<Ext>, <TextFile>ExtractedColumns.<Ext>, and
|
|
111 <TextFile>ExtractedRows.<Ext> for <em>categories</em>, <em>columns</em>, and <em>rows</em> mode
|
|
112 respectively. And <TextFile>Category<CategoryName>.<Ext>
|
|
113 for each category retrieved from each text file. The output file type determines <Ext>
|
|
114 value: csv and tsv for CSV, and TSV files respectively.</p>
|
|
115 <p>This option is ignored for multiple input files.</p>
|
|
116 </dd>
|
|
117 <dt><strong><strong>--rows</strong> <em>"colid,value,criteria..." | "colid,value..." | "colid,mincolvalue,maxcolvalue" | "rownum,rownum,..." | colid | "minrownum,maxrownum"</em></strong></dt>
|
|
118 <dd>
|
|
119 <p>This value is <strong>--rowsmode</strong> specific. In general, it's a list of comma separated column ids and
|
|
120 associated mode specific value. Based on Column ids specification, column label or number, is
|
|
121 controlled by <strong>-c, --colmode</strong> option.</p>
|
|
122 <p>First line containing column labels is always written out. And value comparisons assume
|
|
123 numerical column data.</p>
|
|
124 <p>For <em>rowsbycolvalue</em> mode, input value format contains these triplets:
|
|
125 <em>colid,value, criteria...</em>. Possible values for criteria: <em>le, ge or eq</em>.
|
|
126 Examples:</p>
|
|
127 <div class="OptionsBox">
|
|
128 MolWt,450,le
|
|
129 <br/> MolWt,450,le,LogP,5,le,SumNumNO,10,le,SumNHOH,5,le</div>
|
|
130 <p>For <em>rowsbycolvaluelist</em> mode, input value format is: <em>colid,value...</em>. Examples:</p>
|
|
131 <div class="OptionsBox">
|
|
132 Mol_ID,20
|
|
133 <br/> Mol_ID,20,1002,1115</div>
|
|
134 <p>For <em>rowsbycolvaluerange</em> mode, input value format is: <em>colid,mincolvalue,maxcolvalue</em>. Examples:</p>
|
|
135 <div class="OptionsBox">
|
|
136 MolWt,100,450</div>
|
|
137 <p>For <em>rowbymincolvalue, rowbymaxcolvalue</em> modes, input value format is: <em>colid</em>.</p>
|
|
138 <p>For <em>rownum</em> mode, input value format is: <em>rownum</em>. Default value: <em>2</em>.</p>
|
|
139 <p>For <em>rownumrange</em> mode, input value format is: <em>minrownum, maxrownum</em>. Examples:</p>
|
|
140 <div class="OptionsBox">
|
|
141 10,40</div>
|
|
142 </dd>
|
|
143 <dt><strong><strong>--rowsmode</strong> <em>rowsbycolvalue | rowsbycolvaluelist | rowsbycolvaluerange | rowbymincolvalue | rowbymaxcolvalue | rownums | rownumrange</em></strong></dt>
|
|
144 <dd>
|
|
145 <p>Specify how to extract rows from <em>TextFile(s)</em>. Possible values: <em>rowsbycolvalue, rowsbycolvaluelist, rowsbycolvaluerange,
|
|
146 rowbymincolvalue, rowbymaxcolvalue, rownum, rownumrange</em>. Default value: <em>rownum</em>.</p>
|
|
147 <p>Use <strong>--rows</strong> option to list rows criterion used for extraction of rows from
|
|
148 <em>TextFile(s)</em>.</p>
|
|
149 </dd>
|
|
150 <dt><strong><strong>-w, --workingdir</strong> <em>dirname</em></strong></dt>
|
|
151 <dd>
|
|
152 <p>Location of working directory. Default: current directory.</p>
|
|
153 </dd>
|
|
154 </dl>
|
|
155 <p>
|
|
156 </p>
|
|
157 <h2>EXAMPLES</h2>
|
|
158 <p>To extract first column from a text file and generate a new CSV text file NewSample1.csv,
|
|
159 type:</p>
|
|
160 <div class="ExampleBox">
|
|
161 % ExtractFromTextFiles.pl -r NewSample1 -o Sample1.csv</div>
|
|
162 <p>To extract columns Mol_ID, MolWeight, and NAME from Sample1.csv and generate a new
|
|
163 textfile NewSample1.tsv with no quotes, type:</p>
|
|
164 <div class="ExampleBox">
|
|
165 % ExtractFromTextFiles.pl -m columns -c collabel --columns "Mol_ID,
|
|
166 MolWeight,NAME" --outdelim tab --quote no -r NewSample1
|
|
167 -o Sample1.csv</div>
|
|
168 <p>To extract rows containing values for MolWeight column of less than 450 from
|
|
169 Sample1.csv and generate a new textfile NewSample1.csv, type:</p>
|
|
170 <div class="ExampleBox">
|
|
171 % ExtractFromTextFiles.pl -m rows --rowsmode rowsbycolvalue
|
|
172 -c collabel --rows MolWeight,450,le -r NewSample1
|
|
173 -o Sample1.csv</div>
|
|
174 <p>To extract rows containing values for MolWeight column between 400 and 500 from
|
|
175 Sample1.csv and generate a new textfile NewSample1.csv, type:</p>
|
|
176 <div class="ExampleBox">
|
|
177 % ExtractFromTextFiles.pl -m rows --rowsmode rowsbycolvaluerange
|
|
178 -c collabel --rows MolWeight,450,500 -r NewSample1
|
|
179 -o Sample1.csv</div>
|
|
180 <p>To extract a row containing minimum value for column MolWeight from Sample1.csv and generate
|
|
181 a new textfile NewSample1.csv, type:</p>
|
|
182 <div class="ExampleBox">
|
|
183 % ExtractFromTextFiles.pl -m rows --rowsmode rowbymincolvalue
|
|
184 -c collabel --rows MolWeight -r NewSample1
|
|
185 -o Sample1.csv</div>
|
|
186 <p>
|
|
187 </p>
|
|
188 <h2>AUTHOR</h2>
|
|
189 <p><a href="mailto:msud@san.rr.com">Manish Sud</a></p>
|
|
190 <p>
|
|
191 </p>
|
|
192 <h2>SEE ALSO</h2>
|
|
193 <p><a href="./JoinTextFiles.html">JoinTextFiles.pl</a>, <a href="./MergeTextFilesWithSD.html">MergeTextFilesWithSD.pl</a>, <a href="./ModifyTextFilesFormat.html">ModifyTextFilesFormat.pl</a>, <a href="./SplitTextFiles.html">SplitTextFiles.pl</a>
|
|
194 </p>
|
|
195 <p>
|
|
196 </p>
|
|
197 <h2>COPYRIGHT</h2>
|
|
198 <p>Copyright (C) 2015 Manish Sud. All rights reserved.</p>
|
|
199 <p>This file is part of MayaChemTools.</p>
|
|
200 <p>MayaChemTools is free software; you can redistribute it and/or modify it under
|
|
201 the terms of the GNU Lesser General Public License as published by the Free
|
|
202 Software Foundation; either version 3 of the License, or (at your option)
|
|
203 any later version.</p>
|
|
204 <p> </p><p> </p><div class="DocNav">
|
|
205 <table width="100%" border=0 cellpadding=0 cellspacing=2>
|
|
206 <tr align="left" valign="top"><td width="33%" align="left"><a href="./ExtractFromSequenceFiles.html" title="ExtractFromSequenceFiles.html">Previous</a> <a href="./index.html" title="Table of Contents">TOC</a> <a href="./FilterSDFiles.html" title="FilterSDFiles.html">Next</a></td><td width="34%" align="middle"><strong>March 29, 2015</strong></td><td width="33%" align="right"><strong>ExtractFromTextFiles.pl</strong></td></tr>
|
|
207 </table>
|
|
208 </div>
|
|
209 <br />
|
|
210 <center>
|
|
211 <img src="../../images/h2o2.png">
|
|
212 </center>
|
|
213 </body>
|
|
214 </html>
|