Class FieldMap

java.lang.Object
  |
  +--FieldMap

public class FieldMap
extends java.lang.Object

FieldMap maps MAE (table,field) entries to User (T,F) entries which allows user's to specify variables in terms of what they require and have it mapped to what MAExplorer requires.
This will parse a 1D array of (mT,mF,uT,uF) entries into discrete arrays that are used in the actual field name mappings. Entries with a '*' prefix mean that that entry may be repeated any number of times.

 
 Note:
1. the table definitions are specified in row [0].
2. entries [1:n] are tab-delimited (NOT comma-delimited). However, when the FieldMap associated with an ArrayLayout is saved in the .alo file, it is converted to a comma-delimited string since tabs are reserved for the .alo (N,V) data.
For example (part of the Affymetrix spec): desiredFields[]= {"Table name\tMAE field\tUser field", // Table def at [0] "GipoTable\tLocation\tprobe set", // entries at [1:n] "*QuantTable\tRawIntensity\tAvg Diff", "*QuantTable\tQualCheck\tAbs Call", "GipoTable\tGenBankAcc\tIdentifier", "GipoTable\tClone_ID\tProbe Set", "GipoTable\tGeneName\tDescription" };

This work was produced by Peter Lemkin of the National Cancer Institute, an agency of the United States Government. As a work of the United States Government there is no associated copyright. It is offered as open source software under the Mozilla Public License (version 1.1) subject to the limitations noted in the accompanying LEGAL file.

Version:
$Date: 2002/10/14 19:22:30 $ $Revision: 1.5 $
Author:
P. Lemkin (NCI), B. Stephens(SAIC), G. Thornwall (SAIC), NCI-Frederick, Frederick, MD
See Also:
MAExplorer Home

Field Summary
private static Cvt2Mae cvt
          Global link to Cvt2Mae instance
 java.lang.String[] fieldNamesGQ
          [0:nMapFields-1] field names read from the data file.
 java.lang.String[] fieldsOfUserFile
          [0:nFieldsOfUserFile-1] user fields of current file
 int fmNbr
          unique FieldMap instance number
 int[] idxFUmap
          [0:nMapFields-1] index map from userFieldMap[u] to fieldNames[f].
 int[] idxUFmap
          [0:nMapFields-1] index map from fieldNames[f] to userFieldMap[u].
 java.lang.String[] maeFieldMap
          [0:nMap-1] map of internal MAE Field name
 java.lang.String[] maeTableMap
          [0:nMap-1] map of internal MAE Table name
 java.lang.String mapName
          unique map name
static int masterNbr
          master global counter for field map instances
static int MAX_MAP_SIZE
          initial max map size
 int maxSize
          maximum size of the map
(package private)  java.lang.String newline
          new line character
 int nFieldsOfUserFile
          # of data fields in user file
 int nFieldsUsed
          # of data file fields found in the map and marked true in useTokFlag[].
 int nMap
          # of map entries
 int nMapFieldsGQ
          # ofentries in fieldNamesGQ
 int[] pickedGipoFields
          GIPO fields currently selected by user
 int[] pickedQuantFields
          Quant fields currently selected by user
 int[] pickedSampleFields
          Sample fields currently selected by user
 int remapMode
          sul.REMAP_GIPO, .REMAP_QUANT, .REMAP_SAMPLE 0 if no remap in progress.
 boolean[] repeatMap
          [0:nMap-1] map entry is repeated for each sample.
 int rowWithFields
          row in file where fields are found
 int tCols
          # of fields in table field list
 java.lang.String[] tFields
          [0:tCols-1] field names for table
 java.lang.String[] userFieldMap
          [0:nMap-1] map external user's Field name
 java.lang.String userFile
          full file path for file that contains field names
 java.lang.String[] userGipoFields
          GIPO fields selected by user
 java.lang.String[] userQuantFields
          Quant fields selected by user
 java.lang.String[] userSampleFields
          Sample fields selected by user
 java.lang.String[] userTableMap
          [0:nMap-1] map external user's Table name
 boolean[] useTokFlag
          [0:nMapFields-1] flag fields used to tokenize when parsing input table data corresponding to fieldNames[0:nMapFields-1].
 
Constructor Summary
FieldMap(java.lang.String mapName)
          FieldMap() - constructor
 
Method Summary
 void addEntry(java.lang.String mT, java.lang.String mF, java.lang.String uT, java.lang.String uF)
          addEntry() - add an entry to the list
 void addEntry(java.lang.String mT, java.lang.String mF, java.lang.String uT, java.lang.String uF, boolean repeatFlag)
          addEntry() - add or replace an entry to the FieldMap list.
 void clearMap()
          clearMap() - clear the map and reallocate the tables
 boolean[] genUseTokFlags(java.lang.String[] fieldNamesGQ)
          genUseTokFlags() - generate useTokFlagGQ[0:nMapFields-1] from fieldNames[0:nMapFields-1] and FieldMap userFieldMap[0:nMap-1] data.
 int getFieldsFromUserFile(Cvt2Mae cvt, java.lang.String userFile, int rowWithFields)
          getFieldsFromUserFile() - get fields from user file Return the # of rows found and save the data in fieldsOfUserFile[0:nFieldsOfUserFile-1].
 boolean isDuplicateEntries(java.lang.String mT)
          isDuplicateEntries() - test if duplcate entries for mT entries in mT subtable.
 boolean isEntry(java.lang.String mT, java.lang.String mF)
          isEntry() - has an entry for (mT,mF) in the list Return true if an entry exists.
 int lookupMaeFieldToFieldNameIndex(java.lang.String mFsearch)
          lookupMaeFieldToFieldNameIndex() - lookup FieldName index if exists in the FieldNames[0:nMapFields-1]
 int lookupMaeIndex(java.lang.String mT, java.lang.String mF)
          lookupMaeIndex() - find map index given (mT, mF)
 java.lang.String lookupUserFieldFromMaeTF(java.lang.String mT, java.lang.String mF)
          lookupUserFieldFromMaeTF() - find map index given (mT, mF)
 int lookupUserIndex(java.lang.String uF)
          lookupUserIndex() - find map index given (uF)
 int lookupUserIndex(java.lang.String uT, java.lang.String uF)
          lookupUserIndex() - find map index given (uT, uF)
 java.lang.String lookupUserTFmapPair(java.lang.String mT, java.lang.String mF)
          lookupUserTFmapPair() - findUser "uT,uF" given (mT, mF) Return null if not found.
 java.lang.String lookupUTFmapPair(java.lang.String mT, java.lang.String mF)
          lookupUTFmapPair() - findUser "uT,uF" given (mT, mF)
 boolean rmvEntry(java.lang.String mT, java.lang.String mF)
          rmvEntry() - remove an entry to the list by marking it inactive.
 void setFieldList(int tCols, java.lang.String[] tFields)
          setFieldList() - save the tFields[0:tCols-1]
 java.lang.String toString()
          toString() - make prettyprint string for object.
 void useField(java.lang.String fName)
          useField() - set flag to true in useFieldFlag[] for fName field.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

cvt

private static Cvt2Mae cvt
Global link to Cvt2Mae instance

masterNbr

public static int masterNbr
master global counter for field map instances

MAX_MAP_SIZE

public static int MAX_MAP_SIZE
initial max map size

userFile

public java.lang.String userFile
full file path for file that contains field names

fieldsOfUserFile

public java.lang.String[] fieldsOfUserFile
[0:nFieldsOfUserFile-1] user fields of current file

rowWithFields

public int rowWithFields
row in file where fields are found

nFieldsOfUserFile

public int nFieldsOfUserFile
# of data fields in user file

remapMode

public int remapMode
sul.REMAP_GIPO, .REMAP_QUANT, .REMAP_SAMPLE 0 if no remap in progress. Clear to 0 when finished mapping one of the 3 modes.

userGipoFields

public java.lang.String[] userGipoFields
GIPO fields selected by user

userQuantFields

public java.lang.String[] userQuantFields
Quant fields selected by user

userSampleFields

public java.lang.String[] userSampleFields
Sample fields selected by user

pickedGipoFields

public int[] pickedGipoFields
GIPO fields currently selected by user

pickedQuantFields

public int[] pickedQuantFields
Quant fields currently selected by user

pickedSampleFields

public int[] pickedSampleFields
Sample fields currently selected by user

fmNbr

public int fmNbr
unique FieldMap instance number

maxSize

public int maxSize
maximum size of the map

nMap

public int nMap
# of map entries

maeTableMap

public java.lang.String[] maeTableMap
[0:nMap-1] map of internal MAE Table name

maeFieldMap

public java.lang.String[] maeFieldMap
[0:nMap-1] map of internal MAE Field name

userTableMap

public java.lang.String[] userTableMap
[0:nMap-1] map external user's Table name

userFieldMap

public java.lang.String[] userFieldMap
[0:nMap-1] map external user's Field name

repeatMap

public boolean[] repeatMap
[0:nMap-1] map entry is repeated for each sample. NOTE: this is indicated in the "mT,mF,uT,uF" string by a '*' prefix so it becomes "*mT,mF,uT,uF". This means there may be 1 or more instances of this field and they will be in different columns. (eg. Affy data)

tCols

public int tCols
# of fields in table field list

mapName

public java.lang.String mapName
unique map name

tFields

public java.lang.String[] tFields
[0:tCols-1] field names for table

fieldNamesGQ

public java.lang.String[] fieldNamesGQ
[0:nMapFields-1] field names read from the data file. If a separate GIPO file is used, then this also includes the mcd.sepGIPOfields[] such that mcd.sepGIPOfieldsUsed[] fields are true.

nMapFieldsGQ

public int nMapFieldsGQ
# ofentries in fieldNamesGQ

nFieldsUsed

public int nFieldsUsed
# of data file fields found in the map and marked true in useTokFlag[]. and is less than nMapFields. This is a debugging count and is not used in any other methods.

idxUFmap

public int[] idxUFmap
[0:nMapFields-1] index map from fieldNames[f] to userFieldMap[u]. I.e. idxUFmap[f]= u, such that userFieldMap[u] data equals fieldNames[f]

idxFUmap

public int[] idxFUmap
[0:nMapFields-1] index map from userFieldMap[u] to fieldNames[f]. I.e. idxFUmap[u]= f, such that userFieldMap[u] data same as fieldNames[f]

useTokFlag

public boolean[] useTokFlag
[0:nMapFields-1] flag fields used to tokenize when parsing input table data corresponding to fieldNames[0:nMapFields-1]. This avoids having to parse tokens that are not going to be used - greatly improving the efficiency of the parser.

newline

java.lang.String newline
new line character
Constructor Detail

FieldMap

public FieldMap(java.lang.String mapName)
FieldMap() - constructor
Parameters:
mapName - name of the map
See Also:
clearMap()
Method Detail

clearMap

public void clearMap()
clearMap() - clear the map and reallocate the tables

setFieldList

public void setFieldList(int tCols,
                         java.lang.String[] tFields)
setFieldList() - save the tFields[0:tCols-1]
Parameters:
tFields - [0:tCols-1] names
tCols - number of fields in field list

useField

public void useField(java.lang.String fName)
useField() - set flag to true in useFieldFlag[] for fName field.
Parameters:
fName - field to use

isEntry

public boolean isEntry(java.lang.String mT,
                       java.lang.String mF)
isEntry() - has an entry for (mT,mF) in the list Return true if an entry exists.
Parameters:
mT - Table map
mF - Field map
Returns:
true if an entry exists

addEntry

public void addEntry(java.lang.String mT,
                     java.lang.String mF,
                     java.lang.String uT,
                     java.lang.String uF)
addEntry() - add an entry to the list
Parameters:
mT - Table map
mF - Field map
uT - user Table Map
uF - user Field Map

addEntry

public void addEntry(java.lang.String mT,
                     java.lang.String mF,
                     java.lang.String uT,
                     java.lang.String uF,
                     boolean repeatFlag)
addEntry() - add or replace an entry to the FieldMap list.
Parameters:
mT - Table map
mF - Field map
uT - user Table Map
uF - user Field Map
repeatFlag - map entry is repeated for each sample

rmvEntry

public boolean rmvEntry(java.lang.String mT,
                        java.lang.String mF)
rmvEntry() - remove an entry to the list by marking it inactive.
Parameters:
mT - Table map
mF - Field map
Returns:
true if successful

isDuplicateEntries

public boolean isDuplicateEntries(java.lang.String mT)
isDuplicateEntries() - test if duplcate entries for mT entries in mT subtable.
Parameters:
mT - Table map
Returns:
true if found

lookupMaeIndex

public int lookupMaeIndex(java.lang.String mT,
                          java.lang.String mF)
lookupMaeIndex() - find map index given (mT, mF)
Parameters:
mT - Table map
mF - Field map
Returns:
index if found, else -1 if not found

lookupUserFieldFromMaeTF

public java.lang.String lookupUserFieldFromMaeTF(java.lang.String mT,
                                                 java.lang.String mF)
lookupUserFieldFromMaeTF() - find map index given (mT, mF)
Parameters:
mT - Table map
mF - Field map
Returns:
field else null if not found.

lookupUserIndex

public int lookupUserIndex(java.lang.String uT,
                           java.lang.String uF)
lookupUserIndex() - find map index given (uT, uF)
Parameters:
mT - Table map
mF - Field map
Returns:
index else -1 if not found

lookupUserIndex

public int lookupUserIndex(java.lang.String uF)
lookupUserIndex() - find map index given (uF)
Parameters:
uF - Field map
Returns:
index else -1 if not found

lookupUserTFmapPair

public java.lang.String lookupUserTFmapPair(java.lang.String mT,
                                            java.lang.String mF)
lookupUserTFmapPair() - findUser "uT,uF" given (mT, mF) Return null if not found.
Parameters:
mT - Table map
mF - Field map
Returns:
TF pair else null if not found.

lookupUTFmapPair

public java.lang.String lookupUTFmapPair(java.lang.String mT,
                                         java.lang.String mF)
lookupUTFmapPair() - findUser "uT,uF" given (mT, mF)
Parameters:
mT - Table map
mF - Field map
Returns:
looked up pair else (mT+","+mF) if not found - effectively a no-op.

getFieldsFromUserFile

public int getFieldsFromUserFile(Cvt2Mae cvt,
                                 java.lang.String userFile,
                                 int rowWithFields)
getFieldsFromUserFile() - get fields from user file Return the # of rows found and save the data in fieldsOfUserFile[0:nFieldsOfUserFile-1].
Parameters:
cvt - is the global instance of Cvt2Mae
userFile - is the file
rowWithFields - location in file
Returns:
field if found, else 0 if can't do it.
See Also:
FileTable, FileTable.readTableFieldsFromFile(java.lang.String, int)

genUseTokFlags

public boolean[] genUseTokFlags(java.lang.String[] fieldNamesGQ)
genUseTokFlags() - generate useTokFlagGQ[0:nMapFields-1] from fieldNames[0:nMapFields-1] and FieldMap userFieldMap[0:nMap-1] data. The useTokFlag[] is used by ParseTokens getDelimTokens() to avoid having to parse tokens that are not going to be used - greatly improving the efficiency of the parser.
 This method finds pairs of (u,v)such that
     userFieldMap[u].equals(fieldNames[f])
 and sets
     useTokFlag[f]= true;
     idxUFmap[f]= u;
 
Parameters:
fieldNames - is the input table field names array.
Returns:
useTokFlag[] if found, else null if errors.

lookupMaeFieldToFieldNameIndex

public int lookupMaeFieldToFieldNameIndex(java.lang.String mFsearch)
lookupMaeFieldToFieldNameIndex() - lookup FieldName index if exists in the FieldNames[0:nMapFields-1]
Parameters:
mFsearch - string to search for
Returns:
FieldName index, else return -1.

toString

public java.lang.String toString()
toString() - make prettyprint string for object. NOTE: This is ONLY for visual consumption.
Overrides:
toString in class java.lang.Object
Returns:
pretty print string of this FieldMap instance.