/* Copyright @ 2003, The Institute for Genomic Research (TIGR). All rights reserved. */ /***************************************************************************** * Description: A class that reads a set of tav files and write to MEV files. * Company: TIGR * @author Jianwei (Jerry) Li * @version 1.0 * @Date: Created: 05/12/2003 and modified: 06/07/2004 * Modified History * 06/07/04: Provide the option to make one ann file for a set of slide that * were produced with the same array design. *****************************************************************************/ package org.tigr.microarray.converter; import java.io.IOException; import java.io.BufferedWriter; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.OutputStreamWriter; import java.util.Vector; import javax.swing.JOptionPane; import org.tigr.microarray.MevAttributes; import org.tigr.util.FileReading; import org.tigr.util.MyTimer; import org.tigr.util.io.IOUtil; public class TavMev extends Converter implements MevAttributes{ private String title; int gAnnType; /**************************************************************************** *Constructor: *
Parameters:
* Parameters:
* Return: the writer
****************************************************************************/
private BufferedWriter createAnnoWriter(String fName, String inName, int numSpots,
String[] cValues){
BufferedWriter out;
FileOutputStream fOut;
String annoFileHeader[];
try {
fOut = new FileOutputStream(fName);
out = new BufferedWriter(new OutputStreamWriter(fOut));
annoFileHeader = generateHeader(inName, numSpots, cValues.length, 1);
for(int i=0; i Parameter:
* Return: the header as an array.
**************************************************************************/
private String[] generateHeader(String fName, int numRow, int numCol, int type){
String[] tempHeader = new String[6];
for(int i=0; i Parameter:
* Return: true if it is not modified; otherwise, false.
***************************************************************************/
private boolean isOriginal(Vector inFile, String[] lastLine){
boolean noChange = true;
int numSpot = inFile.size();
int mr=0, mc=0, sr=0, sc=0;
try{
mr = Integer.parseInt(lastLine[2]);
mc = Integer.parseInt(lastLine[3]);
sr = Integer.parseInt(lastLine[4]);
sc = Integer.parseInt(lastLine[5]);
} catch (NumberFormatException nfex){
noChange = false;
return noChange;
}
if((mr * mc * sr * sc) != numSpot){
noChange = false;
}
return noChange;
}
/****************************************************************************
* Description:
* checks if the input file is a tav file.
* Parameters:
* Return: ture if it is; otherwise, false.
**************************************************************************/
private boolean isTavFile(String[] oneLine){
boolean itIs;
switch(oneLine.length){
case 8: case 9: case 10: case 14: case 16: case 17: case 24:
itIs = true;
break;
default: itIs = false;
}
return itIs;
}
/****************************************************************************
* Description:
* sets one row of the anno file.
* Parameters:
* Return: the row.
***************************************************************************/
private String setAnnoLine(int uid, String[] val){
String temp = new String("");
switch(val.length){
case 14: case 17:
temp = uid + TAB + val[0] + TAB + val[1];
break;
case 24:
temp = val[23] + TAB + val[0] + TAB + val[1];
for(int i=13; i Parameters:
* Return: the row.
***************************************************************************/
private String setMevLine(int uid, String[] val){
String temp = new String("");
int i;
if(val.length == 24){
temp = val[23] + TAB + val[6] + TAB + val[7] + TAB;
} else {
temp = uid + TAB + val[6] + TAB + val[7] + TAB;
}
for(i=0; i<6; i++){
temp += val[i] + TAB;
}
switch(val.length){
case 14:
temp += val[10] + TAB + val[11] + TAB + val[12] + TAB + val[13] + TAB +
val[8] + TAB + val[9];
break;
case 17:
temp += val[13] + TAB + val[14] + TAB + val[15] + TAB + val[16] + TAB +
val[8] + TAB + val[9];
break;
case 24:
temp += val[10] + TAB + val[11] + TAB + val[12] + TAB + val[8] + TAB + val[9];
break;
}
return temp;
}
}
gfNames --- the names of GenePix files to be converted.
*
mfNames --- the names of .mev files that is an output.
*****************************************************************************/
public TavMev(Vector inNames, Vector mfNames, String barTitle, int annNum) {
super();
inFileNames = inNames;
outFileNames = mfNames;
title = barTitle;
gAnnType = annNum;
}
/***************************************************************************
* Description:
* overrides an abstract method to implement the main function of class.
**************************************************************************/
public void run () {
boolean noError;
String mevFileName;
String aLine = new String("");
String extraInfo = new String("");
String annoFileNamePath;
String tavFileName, mevLine;
String colValues[];
String annoFile[] = null;
String mevFileHeader[];
String annoFileHeader[];
int numOfFiles, fSize;
int i, j, k;
int slideRow, slideCol;
int maxMetaCol, maxCol;
Vector tavFile;
FileReading fileReader;
BufferedWriter mevWriter = null;
BufferedWriter annoWriter = null;
FileOutputStream mevFileOut = null;
taskEnd = determineTaskEnd();
if(taskEnd == 1){
return;
}
taskEnd <<= 1;
counter = 0;
numOfFiles = inFileNames.size();
for(i=0; i
fName --- ann file name to be written.
*
inName --- the input file name.
*
numSpots --- the number of rows in the input file.
*
fName -- the mev file name that should be written to the file.
*
numRow -- the number of spots (genes/row).
*
numCol -- the number of columns that can determine the version of tav file.
*
type -- the type of header (mev or dat).
*
inFile -- the file to be checked.
*
lastLine -- the last spot of the array.
*
oneLine -- one spot from the file.
*
val -- the tav values of a spot.
*
id -- the unique id.
*
val -- the tav values of a spot.
*