O2Plib.db
Class DbLM

java.lang.Object
  extended by O2Plib.db.LMset
      extended by O2Plib.db.DbLM

public class DbLM
extends LMset

Class DbLM is the Landmark database for Open2Dprot. It contains data for a subset of spots or virtual spots in two samples that are used to define local regions of congruence. These "spots" are called landmarks since they orient the local regions. The data is kept in a landmark database which could be a file landmark.txt (tab-delimited) or landmark.xml. It could later reside in the RDBMS. This class has readers and writers for both the tab-delimited and XML versions.

This file is derived and refactored from Open2Dprot CmpSpots's DbLM.java

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. This notice must be included with the code. The Open2Dprot Mozilla and Legal files are available on http://Open2Dprot.sourceforge.net/.

Version:
$Date: 2005/12/21 23:50:18 $ $Revision: 1.35 $
Author:
P. Lemkin, NCI-Frederick, Frederick, MD, 21702

Nested Class Summary
(package private)  class DbLM.LmsContentHandler
          This class implements the SAX ContentHandler interface and defines callback behavior for the SAX callbacks associated with an XML document's content, stuffing data structures with correct data from xml files.
(package private)  class DbLM.LmsErrorHandler
          LmsErrorHandler class implements the SAX ErrorHandler interface and defines callback behavior for the SAX callbacks associated with an XML document's warnings and errors.
 
Field Summary
static int AP
          Ambiguous Pair - pairing program generated label
 boolean commutativeLMSflag
          flag to allow searching for commutative database entries
static int CP
          Composite Sample Database spot pair.
static int EP
          Extrapolated Pair - by CSD database program
 DbSpot[][] equivLMspotPtr
          Linked list of latched DbSpots that correspond to landmarks in the LM set [nbrLandmarks][2].
static int GS
          Garbage Spot - generated by CSD database or editing programs
static java.lang.String[] helpList
          Help list for the landmark table
static int LM
          LandMark spot [could be virtual landmark] - by CSD database program
 int lmNbrIdx
          Landmark data Table tlm column field indices if tab-delimited tables are being used.
 DbSpot[][] lmSetPtr
          Points to first spot of each LM set in each Sample [0:PARAM_MAXLANDMARKS-1][RSAMPLE:SAMPLE]
static java.lang.String[] lmsFields
          Landmark table fields
 java.lang.String lmsFile
           
 int nUniquePairs
          Size of list of all pairs of samples in the landmark DB samplePairList[RSAMPLE:SAMPLE][0:nUniquePairs-1]
 int nUniqueSamplesInLmsDBlist
          Size of list of all pairs of samples in the landmark DB sampleInLmsDBlist[0:nUniqueSamplesInLmsDBlist-1]
static int PAIRBIT_AP
          Pairing Bit: Ambiguous Pair - pairing program generated label
static int PAIRBIT_CP
           
static int PAIRBIT_EP
          Pairing Bit: Extrapolated Pair - by CSD database program
static int PAIRBIT_GS
          Pairing Bit:Garbage Spot - generated by CSD database or editing programs.
static int PAIRBIT_LM
          Pairing Bit: LandMark spot [could be virtual LM] - by CSD program
static int PAIRBIT_PP
          Pairing Bit: Possible Pair - pairing program generated label
static int PAIRBIT_SP
          Pairing Bit: Sure Pair - pairing program generated label
static int PAIRBIT_US
          Pairing Bit: Unresolved Spot - pairing program generated label
 int pixRsampleIdx
          Landmark data Table tlm column field indices if tab-delimited tables are being used.
 int pixSampleIdx
          Landmark data Table tlm column field indices if tab-delimited tables are being used.
static int PP
          Possible Pair - pairing program generated label
 boolean processingXMLdataFlag
           
 java.lang.String[] sampleInLmsDBlist
          List of samples in the landmark DB that are in the accession DB.
 java.lang.String[][] samplePairList
          List of all pairs of samples in the landmark DB.
static int SP
          Sure Pair - pairing program generated label
 Table tlm
          Landmark database file table
static int US
          Unresolved Spot - pairing program generated label
 boolean useInternalDTDflag
          Use internal "Open2Dprot-Landmark.dtd" file in Landmark.xml output file
 java.lang.String[] validLM
          spot pair labels [nbrLandmarks]: "SM" - same spot in > 1 landmark "NG" - No Good, LM outside either/or Rsample or Sample CW "NL" - spot can't latch to LM (use LM DB coords) "OK" - landmark latched to spot.
static java.lang.String VERSION
          Version for this module
 java.lang.String xmlDate
          XML landmark file date "Date"
 java.lang.String xmlDBname
          XML landmark file database name "DatabaseName"
 int xRsampleIdx
          Landmark data Table tlm column field indices if tab-delimited tables are being used.
 int xSampleIdx
          Landmark data Table tlm column field indices if tab-delimited tables are being used.
 int yRsampleIdx
          Landmark data Table tlm column field indices if tab-delimited tables are being used.
 int ySampleIdx
          Landmark data Table tlm column field indices if tab-delimited tables are being used.
 
Fields inherited from class O2Plib.db.LMset
DIST_THR_LANDMARK, distNearestLM, distNextNearestLM, editRsampleLMSFlag, lmErrDist, MAX_RATIO_ALT_DIST_THRESHOLD, maxLMS, minEffectiveRadius, nbrLandmarks, nearestLM, nextNearestLM, PARAM_DEF_NBR_ALT_LMS, PARAM_MAX_ALT_LMS, PARAM_MAXLANDMARKS, RSAMPLE, rsampleName, SAMPLE, sampleName, setSizeLM, useLM, xlm, ylm
 
Constructor Summary
DbLM()
          DbLM() - set up lndmark part of the database of size nbrLandmarks.
DbLM(int maxLMSallowed)
          DbLM() - set up lndmark part of the database of size nbrLandmarks.
 
Method Summary
 void createNewDbLMtable(java.lang.String lmsFile)
          createNewDbLMtable() - create a new tlm Table.
static java.lang.String cvCodes(int x)
          cvCodes() - map landmark codes to 2 character String names for printing
 java.lang.String cvLMtoDetailedPrintStr(int k)
          cvLMtoDetailedPrintStr() - get the full landmark data for a landmark k
 java.lang.String cvLMtoPrintStr(int k)
          cvLMtoPrintStr() - get the basic landmark data for a landmark k with just xy coords and landmark name.
static int cvPairingCodeName2Code(java.lang.String pairCodeStr)
          cvPairingCodeName2Code() - convert pairing code string to pairing code.
 java.lang.String cvtLMsetSpotsToStr(java.lang.String msg, int k, int nsample)
          cvtLMsetSpotsToStr() - convert ONLY k'throws LM set spots for specified sample to a readable formated string.
 java.lang.String cvtLMsetSpotsToStr(java.lang.String msg, int k, int nsample, Roi dbugRoi, boolean addXYcoordsFlag, boolean addAltLMsetsFlag)
          cvtLMsetSpotsToStr() - convert ONLY k'th LM set spots for specified sample to a readable formated string.
static int cvtPairBit2PairCode(int pairBit)
          cvtPairBit2PairCode() - convert pairing-bit to pairing label code US, SP, PP, AP, EP, CP, GS, LM
static java.awt.Color cvtPairCode2Color(int code)
          cvtPairCode2Color() - convert pairing label code to Color
static int cvtPairCode2PairBit(int code)
          cvtPairCode2PairBit() - convert pairing label code to pairing-bit
 boolean deleteLMsetFromLmsTable(DbSample dbRsample, DbSample dbSample, boolean clearBothSamplesFlag)
          deleteLMsetFromLmsTable() - delete old landmark set from the landmark database table.
 java.lang.String getDumpLMsetSpotsStr(int k, java.lang.String msg)
          getDumpLMsetSpotsStr() - get a printable LM set k string of spots for both samples in readable format.
 java.lang.String getDumpLMsetSpotsStr(int k, java.lang.String msg, Roi rRoiDbug, Roi sRoiDbug, boolean addXYcoordsFlag, boolean addAltLMsetsFlag)
          getDumpLMsetSpotsStr() - get a printable LM set k string of spots for both samples in readable format.
 java.lang.String getLandmarkDBstr()
          getLandmarkDBstr() - get the printable report for all landmarks
 java.lang.String getLMSDBstr(DbSample dbRsample, DbSample dbSample)
          getLMSDBstr() - get landmark set summary as a printable string.
 DbSpot[] getLMsetSpotList(DbSample dbS, int k)
          getLMsetSpotList() - get a list of spots in landmark set k for sample dbS if it exists.
 LMset getLmsSetEntryFromDBtable(java.lang.String rsampleName, java.lang.String sampleName)
          getLmsSetEntryFromDBtable() - lookup and get landmark set in the database table in memory.
 LMset getLmsSetEntryFromDBtable(java.lang.String rsampleName, java.lang.String sampleName, boolean forceSetBothFlag)
          getLmsSetEntryFromDBtable() - lookup and get landmark set in the database table in memory.
 void init()
          init() - reset the DbLM state for both samples.
 java.lang.String[][] listSamplePairs(DbAccession acc)
          ListSamplePairs() - generate a unique list of sample pairs in the database.
 java.lang.String[] listUniqueSamplesInLandmarkDB(DbAccession acc)
          listUniqueSamplesInLandmarkDB() - generate a unique list of sample pairs in the database.
 boolean loadLandmarkDatabase(java.lang.String lmsFile, int lmsFormatMode)
          loadLandmarkDatabase() - load landmarks database table
 boolean lookupLandmarkTableIndices()
          lookupLandmarkTableIndices() - lookup SSF data table indices Note: the table contains (pixRsample,pixSample,lmNbr,xRsample,yRsample,xSample,ySample) So look for both field name sets.
 java.lang.String[] lookupPairedSamplesList(java.lang.String rName)
          lookupPairedSamplesList() - lookup list of all pairs of (Rsample,Sample) pairs in the landmark database such that the Rsample is rName.
 boolean lookupSamplePairLMS(DbSample dbRsample, DbSample dbSample, boolean commutativeLMSflag)
          lookupSamplePairLMS() - lookup specific LMset pair (Rsample,Sample) from landmarks data table.
 boolean readLandmarkDatabase(java.lang.String lmsFile, int lmsFormatMode, boolean commutativeLMSflag)
          readLandmarkDatabase() - read landmark database data from tab-delimited data file or XML data file into the Table tlm.
 boolean readLandmarkDatabase(java.lang.String rsampleName, java.lang.String sampleName, java.lang.String lmsFile, int lmsFormatMode, boolean commutativeLMSflag)
          readLandmarkDatabase() - read landmark database data from tab-delimited data file or XML data file into the Table tlm.
 boolean readLandmarksTable(int lmsFormatMode)
          readLandmarksTable() - find (Rsample,Sample) in landmarks database table using the previously definedlmsFile path.
 Table readLandmarkXML(java.lang.String XMLfileName)
          readLandmarkXML() - read landmark database data from XML file into Table.
 boolean saveLmsDB2DelimFile(java.lang.String lmsFile, java.lang.String delim, boolean makeBkupCopyFlag)
          saveLmsDB2DelimFile() - save the landmark database into a delimited string file.
 boolean saveLmsDB2XMLfile(java.lang.String lmsXMLfile, boolean makeBkupCopyFlag)
          saveLmsDB2XMLfile() - save landmark database into an XML file file.
 boolean saveLMsetInDBtable(LMset c)
          saveLMsetInDBtable() - save the LM set in the in-core landmark database table.
 boolean saveLMsetInDBtable(LMset c, java.lang.String rsampleName, java.lang.String sampleName)
          saveLMsetInDBtable() - save the LM set in the in-core landmark database table.
 void setRsampleAndSampleNames(java.lang.String rsampleName, java.lang.String sampleName)
          setRsampleAndSampleNames() - set the Rsample and Sample names
 void setUseInternalDTDflag(boolean useInternalDTDflag)
          setUseInternalDTDflag() - set the use internal DTD flag.
 boolean writeLandmarksTable(java.lang.String lmsFile, int lmsFormatMode, boolean makeBkupCopyFlag)
          writeLandmarksTable() - write out the landmarks table in the specified format.
 
Methods inherited from class O2Plib.db.LMset
addLandmarkToLMset, appendLandmarkToLMset, changeLandmarkToLMset, clearLMset, clearSampleLMset, cloneLMset, computeLMSradii, copyLMset, copyRsampleLMset, copySampleLMset, cvLMsetToPrintStr, cvLMSIdx2Name, cvLMSname2Idx, cvXYtoOtherSample, delLandmarkFromLMset, delLandmarkFromLMset, findLMbyXYcoords, findLMbyXYcoords, getLMSDBbyNamestr, getLMSDBbyNamestr, getLMsetStr, getLMSstr, getSpotLMsetRadiiStr, getSpotLMsetRadiiStr, getSpotLMSradiiStr, growLMset, initLMset, mapRsampleXYtoSample, mapRsampleXYtoSampleLMset, mapSampleXYtoRsample, mapSampleXYtoRsampleLMset, setBothLandmarksToLMset, setLMSsetRsampleAndSampleNames, setRsampleEditEnable, toBriefString, toBriefXML, toFullXML, toString, toXML, toXML
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

VERSION

public static final java.lang.String VERSION
Version for this module

See Also:
Constant Field Values

US

public static final int US
Unresolved Spot - pairing program generated label

See Also:
Constant Field Values

SP

public static final int SP
Sure Pair - pairing program generated label

See Also:
Constant Field Values

PP

public static final int PP
Possible Pair - pairing program generated label

See Also:
Constant Field Values

AP

public static final int AP
Ambiguous Pair - pairing program generated label

See Also:
Constant Field Values

EP

public static final int EP
Extrapolated Pair - by CSD database program

See Also:
Constant Field Values

CP

public static final int CP
Composite Sample Database spot pair. The CSD' is a statistical representation of a set of effective sample replicates generated by the database program .

See Also:
Constant Field Values

GS

public static final int GS
Garbage Spot - generated by CSD database or editing programs

See Also:
Constant Field Values

LM

public static final int LM
LandMark spot [could be virtual landmark] - by CSD database program

See Also:
Constant Field Values

PAIRBIT_US

public static final int PAIRBIT_US
Pairing Bit: Unresolved Spot - pairing program generated label

See Also:
Constant Field Values

PAIRBIT_SP

public static final int PAIRBIT_SP
Pairing Bit: Sure Pair - pairing program generated label

See Also:
Constant Field Values

PAIRBIT_PP

public static final int PAIRBIT_PP
Pairing Bit: Possible Pair - pairing program generated label

See Also:
Constant Field Values

PAIRBIT_AP

public static final int PAIRBIT_AP
Pairing Bit: Ambiguous Pair - pairing program generated label

See Also:
Constant Field Values

PAIRBIT_EP

public static final int PAIRBIT_EP
Pairing Bit: Extrapolated Pair - by CSD database program

See Also:
Constant Field Values

PAIRBIT_CP

public static final int PAIRBIT_CP
See Also:
Constant Field Values

PAIRBIT_GS

public static final int PAIRBIT_GS
Pairing Bit:Garbage Spot - generated by CSD database or editing programs.

See Also:
Constant Field Values

PAIRBIT_LM

public static final int PAIRBIT_LM
Pairing Bit: LandMark spot [could be virtual LM] - by CSD program

See Also:
Constant Field Values

lmsFile

public java.lang.String lmsFile

commutativeLMSflag

public boolean commutativeLMSflag
flag to allow searching for commutative database entries


validLM

public java.lang.String[] validLM
spot pair labels [nbrLandmarks]: "SM" - same spot in > 1 landmark "NG" - No Good, LM outside either/or Rsample or Sample CW "NL" - spot can't latch to LM (use LM DB coords) "OK" - landmark latched to spot.


equivLMspotPtr

public DbSpot[][] equivLMspotPtr
Linked list of latched DbSpots that correspond to landmarks in the LM set [nbrLandmarks][2]. If there is NO spot corresponding to the landmark since it is less than the MAX_LM_LATCH_THR, then the entry is null.


lmSetPtr

public DbSpot[][] lmSetPtr
Points to first spot of each LM set in each Sample [0:PARAM_MAXLANDMARKS-1][RSAMPLE:SAMPLE]


samplePairList

public java.lang.String[][] samplePairList
List of all pairs of samples in the landmark DB. samplePairList[RSAMPLE:SAMPLE][0:nUniquePairs-1]


nUniquePairs

public int nUniquePairs
Size of list of all pairs of samples in the landmark DB samplePairList[RSAMPLE:SAMPLE][0:nUniquePairs-1]


sampleInLmsDBlist

public java.lang.String[] sampleInLmsDBlist
List of samples in the landmark DB that are in the accession DB. sampleInLmsDBlist[0:nUniqueSamplesInLmsDBlist-1]


nUniqueSamplesInLmsDBlist

public int nUniqueSamplesInLmsDBlist
Size of list of all pairs of samples in the landmark DB sampleInLmsDBlist[0:nUniqueSamplesInLmsDBlist-1]


helpList

public static java.lang.String[] helpList
Help list for the landmark table


lmsFields

public static java.lang.String[] lmsFields
Landmark table fields


pixRsampleIdx

public int pixRsampleIdx
Landmark data Table tlm column field indices if tab-delimited tables are being used.


pixSampleIdx

public int pixSampleIdx
Landmark data Table tlm column field indices if tab-delimited tables are being used.


lmNbrIdx

public int lmNbrIdx
Landmark data Table tlm column field indices if tab-delimited tables are being used.


xRsampleIdx

public int xRsampleIdx
Landmark data Table tlm column field indices if tab-delimited tables are being used.


yRsampleIdx

public int yRsampleIdx
Landmark data Table tlm column field indices if tab-delimited tables are being used.


xSampleIdx

public int xSampleIdx
Landmark data Table tlm column field indices if tab-delimited tables are being used.


ySampleIdx

public int ySampleIdx
Landmark data Table tlm column field indices if tab-delimited tables are being used.


tlm

public Table tlm
Landmark database file table


xmlDBname

public java.lang.String xmlDBname
XML landmark file database name "DatabaseName"


xmlDate

public java.lang.String xmlDate
XML landmark file date "Date"


processingXMLdataFlag

public boolean processingXMLdataFlag

useInternalDTDflag

public boolean useInternalDTDflag
Use internal "Open2Dprot-Landmark.dtd" file in Landmark.xml output file

Constructor Detail

DbLM

public DbLM()
DbLM() - set up lndmark part of the database of size nbrLandmarks.


DbLM

public DbLM(int maxLMSallowed)
DbLM() - set up lndmark part of the database of size nbrLandmarks.

Parameters:
maxLMSallowed - to change the default.
Method Detail

init

public void init()
init() - reset the DbLM state for both samples.


createNewDbLMtable

public void createNewDbLMtable(java.lang.String lmsFile)
createNewDbLMtable() - create a new tlm Table. Use the lmsFields[] names for the table. Use the current landmark lmsFile name when creating the table. Set the editRsampleLMSFlag to true so can add entries.

Parameters:
lmsFile - name of the landmark database

cvCodes

public static java.lang.String cvCodes(int x)
cvCodes() - map landmark codes to 2 character String names for printing

Parameters:
x - is the code (SP, PP, AP, US, EP, GS, or LM)
Returns:
code name ("SP", "PP", "AP", "US", "EP" "CP", "GS", or "LM"), else "**" if illegal code.

cvPairingCodeName2Code

public static int cvPairingCodeName2Code(java.lang.String pairCodeStr)
cvPairingCodeName2Code() - convert pairing code string to pairing code. Note it only checks the first (unique) letter of the pair code so "P" and "PP" will be the same code.

Parameters:
pairCodeStr - is one of "SP", "PP", "AP", "US", "EP" "CP", "GS", "LM"
Returns:
pairing code SP, PP, AP, US, EP, GS, LM or return -1 if not found.

readLandmarkDatabase

public boolean readLandmarkDatabase(java.lang.String rsampleName,
                                    java.lang.String sampleName,
                                    java.lang.String lmsFile,
                                    int lmsFormatMode,
                                    boolean commutativeLMSflag)
readLandmarkDatabase() - read landmark database data from tab-delimited data file or XML data file into the Table tlm.

Parameters:
rsampleName - reference gel name
sampleName - sample to pair with the reference sample
lmsFile - name of the landmark database
lmsFormatMode - - IO_FORMAT_xxx input mode
commutativeLMSflag - if true, search for either (Rsample,Sample) or (Sample,Rsample) in the landmark database.
Returns:
true if succeed

setRsampleAndSampleNames

public void setRsampleAndSampleNames(java.lang.String rsampleName,
                                     java.lang.String sampleName)
setRsampleAndSampleNames() - set the Rsample and Sample names

Parameters:
rsampleName - set default Rsample
sampleName - set default Sample

readLandmarkDatabase

public boolean readLandmarkDatabase(java.lang.String lmsFile,
                                    int lmsFormatMode,
                                    boolean commutativeLMSflag)
readLandmarkDatabase() - read landmark database data from tab-delimited data file or XML data file into the Table tlm. Note: this does NOT set the (rsampleName,sampleName) fields. It assumes that they were set previously with setRsampleAndSampleNames().

Parameters:
lmsFile -
lmsFormatMode - - IO_FORMAT_xxx input mode
commutativeLMSflag -
Returns:
true if succeed
See Also:
setRsampleAndSampleNames(java.lang.String, java.lang.String)

listSamplePairs

public java.lang.String[][] listSamplePairs(DbAccession acc)
ListSamplePairs() - generate a unique list of sample pairs in the database. It uses pairs data in landmark DB and accession info from accession DB.

Parameters:
acc - is Accession DB
Returns:
samplePairList[RSAMPLE:SAMPLE][0:nUniquePairs-1]

lookupPairedSamplesList

public java.lang.String[] lookupPairedSamplesList(java.lang.String rName)
lookupPairedSamplesList() - lookup list of all pairs of (Rsample,Sample) pairs in the landmark database such that the Rsample is rName.

Parameters:
rName - is name of the Rsample
Returns:
unique list of Samples that are paired with the Rsample, else null if none.

listUniqueSamplesInLandmarkDB

public java.lang.String[] listUniqueSamplesInLandmarkDB(DbAccession acc)
listUniqueSamplesInLandmarkDB() - generate a unique list of sample pairs in the database. It uses pairs data in landmark DB and accession info from accession DB.

Parameters:
acc - is Accession DB
Returns:
samplePairList[RSAMPLE:SAMPLE][0:nUniquePairs-1]

setUseInternalDTDflag

public void setUseInternalDTDflag(boolean useInternalDTDflag)
setUseInternalDTDflag() - set the use internal DTD flag. This is used to decide if add internal "Open2Dprot-Landmark.dtd" file in Landmark.xml XML output file.

Parameters:
useInternalDTDflag - status to set

writeLandmarksTable

public boolean writeLandmarksTable(java.lang.String lmsFile,
                                   int lmsFormatMode,
                                   boolean makeBkupCopyFlag)
writeLandmarksTable() - write out the landmarks table in the specified format.

Parameters:
lmsFile - - name of output landmark file to be generated.
lmsFormatMode - - Either IO_FORMAT_TAB_DELIM or IO_FORMAT_xml format
makeBkupCopyFlag - - first make backup copy of file w/.bak extension.
Returns:
true if succeed

saveLmsDB2XMLfile

public boolean saveLmsDB2XMLfile(java.lang.String lmsXMLfile,
                                 boolean makeBkupCopyFlag)
saveLmsDB2XMLfile() - save landmark database into an XML file file.

Parameters:
lmsXMLfile - - name of XML file to be generated.
makeBkupCopyFlag - - first make backup copy of file with a .bak extension.
Returns:
true if succeed

saveLmsDB2DelimFile

public boolean saveLmsDB2DelimFile(java.lang.String lmsFile,
                                   java.lang.String delim,
                                   boolean makeBkupCopyFlag)
saveLmsDB2DelimFile() - save the landmark database into a delimited string file. Delimiters could be "," or "\t", or some string.

Parameters:
lmsFile - - name of delimted file to be generated.
delim - is the delimiter string (or character)
makeBkupCopyFlag - - make backup copy of file first with .bak extension.
Returns:
true if succeed, error in errMsg.

lookupLandmarkTableIndices

public boolean lookupLandmarkTableIndices()
lookupLandmarkTableIndices() - lookup SSF data table indices Note: the table contains (pixRsample,pixSample,lmNbr,xRsample,yRsample,xSample,ySample) So look for both field name sets.

Returns:
true if succeed.

loadLandmarkDatabase

public boolean loadLandmarkDatabase(java.lang.String lmsFile,
                                    int lmsFormatMode)
loadLandmarkDatabase() - load landmarks database table

Parameters:
lmsFile - is name of landmark database file full path
lmsFormatMode - - IO_FORMAT_xxx input mode
Returns:
true if succeed

readLandmarksTable

public boolean readLandmarksTable(int lmsFormatMode)
readLandmarksTable() - find (Rsample,Sample) in landmarks database table using the previously definedlmsFile path.

Parameters:
lmsFormatMode - - IO_FORMAT_xxx input mode
Returns:
true if succeed

lookupSamplePairLMS

public boolean lookupSamplePairLMS(DbSample dbRsample,
                                   DbSample dbSample,
                                   boolean commutativeLMSflag)
lookupSamplePairLMS() - lookup specific LMset pair (Rsample,Sample) from landmarks data table.

Parameters:
dbRsample - - DBsample for Rsample
dbSample - - DBsample for of Sample
commutativeLMSflag - - set if can search on (Sample,Rsample) as well as (Rsample,Sample).
Returns:
true if found data. Data is in DbLM instance state LMset base class instance.

getLMSDBstr

public java.lang.String getLMSDBstr(DbSample dbRsample,
                                    DbSample dbSample)
getLMSDBstr() - get landmark set summary as a printable string. This includes the samples CWs, and the list of landmark coordinates and whether the landmarks are inside the CWs.

Parameters:
dbRsample - is Rsample
dbSample - is Sample
Returns:
string if found data. Data is in DbLM instance state.

saveLMsetInDBtable

public boolean saveLMsetInDBtable(LMset c)
saveLMsetInDBtable() - save the LM set in the in-core landmark database table. This does NOT write it out to the disk.

Parameters:
c - is LMset to update in the landmark database table.
rsampleName - reference gel name
sampleName - sample to pair with the reference sample
Returns:
true if succeed [TODO]

saveLMsetInDBtable

public boolean saveLMsetInDBtable(LMset c,
                                  java.lang.String rsampleName,
                                  java.lang.String sampleName)
saveLMsetInDBtable() - save the LM set in the in-core landmark database table. This does NOT write it out to the disk.

Parameters:
c - is LMset to update in the landmark database table.
rsampleName - reference gel name
sampleName - sample to pair with the reference sample
Returns:
true if succeed [TODO]

getLmsSetEntryFromDBtable

public LMset getLmsSetEntryFromDBtable(java.lang.String rsampleName,
                                       java.lang.String sampleName)
getLmsSetEntryFromDBtable() - lookup and get landmark set in the database table in memory.

Parameters:
rsampleName - reference gel name
sampleName - sample to pair with the reference sample
Returns:
the landmark set in a LMset object if found, else null

getLmsSetEntryFromDBtable

public LMset getLmsSetEntryFromDBtable(java.lang.String rsampleName,
                                       java.lang.String sampleName,
                                       boolean forceSetBothFlag)
getLmsSetEntryFromDBtable() - lookup and get landmark set in the database table in memory.

Parameters:
rsampleName - reference gel name
sampleName - sample to pair with the reference sample
forceSetBothFlag - else use the edit flag
Returns:
the landmark set in a LMset object if found, else null

deleteLMsetFromLmsTable

public boolean deleteLMsetFromLmsTable(DbSample dbRsample,
                                       DbSample dbSample,
                                       boolean clearBothSamplesFlag)
deleteLMsetFromLmsTable() - delete old landmark set from the landmark database table.

Parameters:
dbRsample - is the Rsample
dbSample - is the Sample
clearBothSamplesFlag - to clear xy values for both the Rsample and the Sample
Returns:
true if succeed [TODO]

getLandmarkDBstr

public java.lang.String getLandmarkDBstr()
getLandmarkDBstr() - get the printable report for all landmarks
 E.g., 
 LM[A]= (209,191, 228,177)
 LM[B]= (178,153, 197,142)
            . . .    
          x   y    x   y
         Rsample  Sample 

Returns:
report string

cvLMtoPrintStr

public java.lang.String cvLMtoPrintStr(int k)
cvLMtoPrintStr() - get the basic landmark data for a landmark k with just xy coords and landmark name.
 E.g., 
 LM[B]= (178,153, 197,142)
          x   y    x   y
         Rsample  Sample 

Returns:
report string

cvLMtoDetailedPrintStr

public java.lang.String cvLMtoDetailedPrintStr(int k)
cvLMtoDetailedPrintStr() - get the full landmark data for a landmark k
 E.g., 
 Min R[B]=18 distNLM[42,36] to NLMs[C,C], distNNLM[49,47] to NNLMs[A,A]
 i.e.  radius   dBtoC1 dBtoC2                 dBtoA1 dBtoA2

Overrides:
cvLMtoDetailedPrintStr in class LMset
Returns:
report string

cvtPairCode2Color

public static java.awt.Color cvtPairCode2Color(int code)
cvtPairCode2Color() - convert pairing label code to Color

Parameters:
code - is pairing label code: US, SP, PP, AP, EP, etc.
Returns:
color, else Color.black

cvtPairCode2PairBit

public static int cvtPairCode2PairBit(int code)
cvtPairCode2PairBit() - convert pairing label code to pairing-bit

Parameters:
code - is pairing label code: US, SP, PP, AP, EP, CP, GS, LM
Returns:
PAIRBIT_xxx else -1 if not found.

cvtPairBit2PairCode

public static int cvtPairBit2PairCode(int pairBit)
cvtPairBit2PairCode() - convert pairing-bit to pairing label code US, SP, PP, AP, EP, CP, GS, LM

Parameters:
pair - bit PAIRBIT_xx where* xx is US, SP, PP, AP, EP, CP, GS, LM
Returns:
pairing code else -1 if not found.

cvtLMsetSpotsToStr

public java.lang.String cvtLMsetSpotsToStr(java.lang.String msg,
                                           int k,
                                           int nsample)
cvtLMsetSpotsToStr() - convert ONLY k'throws LM set spots for specified sample to a readable formated string. Use primarily for debugging...

Parameters:
msg - is optional msg to print
k - is Landmark set k to print
nsample - is either RSAMPLE or SAMPLE
Returns:
string for printing

cvtLMsetSpotsToStr

public java.lang.String cvtLMsetSpotsToStr(java.lang.String msg,
                                           int k,
                                           int nsample,
                                           Roi dbugRoi,
                                           boolean addXYcoordsFlag,
                                           boolean addAltLMsetsFlag)
cvtLMsetSpotsToStr() - convert ONLY k'th LM set spots for specified sample to a readable formated string. Use primarily for debugging...

Parameters:
msg - is optional msg to print
k - is Landmark set k to print
nsample - is either RSAMPLE or SAMPLE
dbugRoi - to filter data by (x,y) if not null (i.e. defined)
addXYcoordsFlag - to add thespot X,Y coordinates
addAltLMsetsFlag - to add the alternate landmark set lists
Returns:
string for printing

getDumpLMsetSpotsStr

public java.lang.String getDumpLMsetSpotsStr(int k,
                                             java.lang.String msg)
getDumpLMsetSpotsStr() - get a printable LM set k string of spots for both samples in readable format. For DEBUG...

Parameters:
k - is the LM set to get
msg - is message to print if not null
Returns:
printable string of the spots in the LM set k.

getDumpLMsetSpotsStr

public java.lang.String getDumpLMsetSpotsStr(int k,
                                             java.lang.String msg,
                                             Roi rRoiDbug,
                                             Roi sRoiDbug,
                                             boolean addXYcoordsFlag,
                                             boolean addAltLMsetsFlag)
getDumpLMsetSpotsStr() - get a printable LM set k string of spots for both samples in readable format. For DEBUG...

Parameters:
k - is the LM set to get
msg - is message to print if not null
rRoiDbug - to filter data by Rsample(x,y) if not null
sRoiDbug - to filter data by Sample(x,y) if not null
addXYcoordsFlag - to add the spots XY coordinates
addAltLMsetsFlag - to add the alternate landmark set lists
Returns:
printable string of the spots in the LM set k.

getLMsetSpotList

public DbSpot[] getLMsetSpotList(DbSample dbS,
                                 int k)
getLMsetSpotList() - get a list of spots in landmark set k for sample dbS if it exists.

Parameters:
dbS - is the sample to get
k - is the LM set to get
Returns:
list of spots, else null

readLandmarkXML

public Table readLandmarkXML(java.lang.String XMLfileName)
readLandmarkXML() - read landmark database data from XML file into Table.

Parameters:
XMLfileName - to read
Returns:
table instance if succeed else null