5093 |
10 Sep 09 |
nicklas |
1 |
/** |
5093 |
10 Sep 09 |
nicklas |
$Id$ |
5093 |
10 Sep 09 |
nicklas |
3 |
|
5093 |
10 Sep 09 |
nicklas |
Copyright (C) 2009 Nicklas Nordborg |
5093 |
10 Sep 09 |
nicklas |
5 |
|
5093 |
10 Sep 09 |
nicklas |
This file is part of BASE - BioArray Software Environment. |
5093 |
10 Sep 09 |
nicklas |
Available at http://base.thep.lu.se/ |
5093 |
10 Sep 09 |
nicklas |
8 |
|
5093 |
10 Sep 09 |
nicklas |
BASE is free software; you can redistribute it and/or |
5093 |
10 Sep 09 |
nicklas |
modify it under the terms of the GNU General Public License |
5093 |
10 Sep 09 |
nicklas |
as published by the Free Software Foundation; either version 3 |
5093 |
10 Sep 09 |
nicklas |
of the License, or (at your option) any later version. |
5093 |
10 Sep 09 |
nicklas |
13 |
|
5093 |
10 Sep 09 |
nicklas |
BASE is distributed in the hope that it will be useful, |
5093 |
10 Sep 09 |
nicklas |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
5093 |
10 Sep 09 |
nicklas |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
5093 |
10 Sep 09 |
nicklas |
GNU General Public License for more details. |
5093 |
10 Sep 09 |
nicklas |
18 |
|
5093 |
10 Sep 09 |
nicklas |
You should have received a copy of the GNU General Public License |
5093 |
10 Sep 09 |
nicklas |
along with BASE. If not, see <http://www.gnu.org/licenses/>. |
5093 |
10 Sep 09 |
nicklas |
21 |
*/ |
5093 |
10 Sep 09 |
nicklas |
22 |
package net.sf.basedb.util.importer.spotdata; |
5093 |
10 Sep 09 |
nicklas |
23 |
|
5093 |
10 Sep 09 |
nicklas |
24 |
import net.sf.basedb.util.parser.FlatFileParser; |
5093 |
10 Sep 09 |
nicklas |
25 |
|
5093 |
10 Sep 09 |
nicklas |
26 |
/** |
5093 |
10 Sep 09 |
nicklas |
Parser that is responsible for extracting extra float values |
5093 |
10 Sep 09 |
nicklas |
from the 'spot' section in a BASEfile. Extra value parsers |
5093 |
10 Sep 09 |
nicklas |
are created in the first pass and used in the second pass. |
5093 |
10 Sep 09 |
nicklas |
30 |
|
5093 |
10 Sep 09 |
nicklas |
@author Nicklas |
5093 |
10 Sep 09 |
nicklas |
@version 2.14 |
5093 |
10 Sep 09 |
nicklas |
@base.modified $Date$ |
5093 |
10 Sep 09 |
nicklas |
34 |
*/ |
5093 |
10 Sep 09 |
nicklas |
35 |
public class ExtraFloatParser |
5093 |
10 Sep 09 |
nicklas |
36 |
{ |
5093 |
10 Sep 09 |
nicklas |
37 |
|
5093 |
10 Sep 09 |
nicklas |
38 |
private final String id; |
5093 |
10 Sep 09 |
nicklas |
39 |
private final int valueIndex; |
5093 |
10 Sep 09 |
nicklas |
40 |
|
5093 |
10 Sep 09 |
nicklas |
41 |
/** |
5093 |
10 Sep 09 |
nicklas |
Creates a new extra value parser. |
5093 |
10 Sep 09 |
nicklas |
@param id The external id of the extra value type |
5093 |
10 Sep 09 |
nicklas |
@param valueIndex The index of the extra value column |
5093 |
10 Sep 09 |
nicklas |
relative the first column of assay data |
5093 |
10 Sep 09 |
nicklas |
46 |
*/ |
5093 |
10 Sep 09 |
nicklas |
47 |
public ExtraFloatParser(String id, int valueIndex) |
5093 |
10 Sep 09 |
nicklas |
48 |
{ |
5093 |
10 Sep 09 |
nicklas |
49 |
this.id = id; |
5093 |
10 Sep 09 |
nicklas |
50 |
this.valueIndex = valueIndex; |
5093 |
10 Sep 09 |
nicklas |
51 |
} |
5093 |
10 Sep 09 |
nicklas |
52 |
|
5093 |
10 Sep 09 |
nicklas |
53 |
/** |
5093 |
10 Sep 09 |
nicklas |
Get the external id of the extra value type. |
5093 |
10 Sep 09 |
nicklas |
55 |
*/ |
5093 |
10 Sep 09 |
nicklas |
56 |
public String getId() |
5093 |
10 Sep 09 |
nicklas |
57 |
{ |
5093 |
10 Sep 09 |
nicklas |
58 |
return id; |
5093 |
10 Sep 09 |
nicklas |
59 |
} |
5093 |
10 Sep 09 |
nicklas |
60 |
|
5093 |
10 Sep 09 |
nicklas |
61 |
/** |
5093 |
10 Sep 09 |
nicklas |
Get the extra value from the data. If the section contains data for |
5093 |
10 Sep 09 |
nicklas |
multiple bioassays (eg. a matrix BASEfile) this method is called multiple |
5093 |
10 Sep 09 |
nicklas |
times (with different 'firstIndex' value) for each row. |
5093 |
10 Sep 09 |
nicklas |
65 |
|
5093 |
10 Sep 09 |
nicklas |
@param data The current data line |
5093 |
10 Sep 09 |
nicklas |
@param firstIndex The index of the first data column that contains data |
5093 |
10 Sep 09 |
nicklas |
for the current bioassay |
5093 |
10 Sep 09 |
nicklas |
@return The extracted float value, or Float.NaN if the |
5093 |
10 Sep 09 |
nicklas |
value is invalid (results in not inserting it) |
5093 |
10 Sep 09 |
nicklas |
71 |
*/ |
5093 |
10 Sep 09 |
nicklas |
72 |
public float getValue(FlatFileParser.Data data, int firstIndex) |
5093 |
10 Sep 09 |
nicklas |
73 |
{ |
7665 |
20 Mar 19 |
nicklas |
74 |
Float f = data.getFloat(valueIndex + firstIndex, null, true); |
7665 |
20 Mar 19 |
nicklas |
75 |
return f == null ? Float.NaN : f; |
5093 |
10 Sep 09 |
nicklas |
76 |
} |
5093 |
10 Sep 09 |
nicklas |
77 |
|
5093 |
10 Sep 09 |
nicklas |
78 |
} |