IMPACT
Class FileFormatConverter

java.lang.Object
  extended by IMPACT.FileFormatConverter

public class FileFormatConverter
extends java.lang.Object

Implementation of functions to read/write several formats of MSA files. Accepts at most 2500 taxa, and 10000 sites (sequence size).

Author:
Emanuel Maldonado
See Also:
GUIFileFormatConverter, AlignmentEditor

Field Summary
static java.lang.String[] CFILE_FORMATS
          Collection of format names, only for ConTest.
static java.lang.String CLUSTAL_F
          CLUSTAL format name
static char CLUSTAL_TYPE
          CLUSTAL format type
static java.lang.String DCSE_F
          DCSE format name (discontinued).
static int DESTINATION
          Ouput files
static java.lang.String FASTA_F
          FASTA format name
static char FASTA_TYPE
          FASTA format type
static java.lang.String[] FILEFORMATS
          Collection of format names.
static java.lang.String MASE_F
          MASE format name
static char MASE_TYPE
          MASE format type
static java.lang.String[] PHYLIP_FTYPES
          PHYLIP Format types for either Interleaved or Sequential: Classic/Extended
static char PHYLIP_TYPE
          PHYLIP format type
static java.lang.String PHYLIPG_F
          PHYLIP GENERIC format name
static java.lang.String PHYLIPI_F
          PHYLIP INTERLEAVED format name
static java.lang.String PHYLIPS_F
          PHYLIP SEQUENTIAL format name
static int SOURCE
          Input files
 
Constructor Summary
FileFormatConverter()
          Initialize File Converter.
FileFormatConverter(java.io.File fromfl, java.lang.String fromfmt, java.io.File tofl, java.lang.String tofmt)
          Build file converter with source and destination files.
FileFormatConverter(java.io.File file, java.lang.String format, int io)
          Build file converter with file and format.
 
Method Summary
 boolean convert_totmp(java.lang.String[] phy_options)
          Creation of a temporary file, for phyml submission.

Temporary file must be of format Phylip (Interleaved or Sequential).

If source file, is of any other format convert to either Interleaved or Sequential according to user choice in phyml options.
 boolean convert(java.io.File fromfl, java.lang.String fromfmt, java.io.File tofl, java.lang.String tofmt)
          Convert from file with format, to file with format.
 int getMaxTaxaNameSize(java.lang.String[] taxa)
          Get maximum size for given taxa names.
 int getSequenceCount()
          Get number of sequences, possibly if file loaded.
 java.lang.String[][] getSequences()
          Get sequences.
 int getSiteCount()
          Get number of sites, possibly if file loaded.
 java.lang.String[] getTaxaNames()
          Get taxa names.
 boolean readMSAfile()
          Read MSA file for instantiated source file and format.
 void setPhylipFormatType(java.lang.String type)
          Use phylip format type in read/write phylip files.
 void setSequenceCount(int count)
          Set number of sequences to value of count.
 void setSequences(java.lang.String[][] msa)
          Set sequences to msa value.
 void setSiteCount(int count)
          Set number of sites to value of count.
 void setTaxaNames(java.lang.String[] names)
          Set taxa names to names value.
 void writeMSAFile()
          Write to instantiated destination MSA file and format.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SOURCE

public static final int SOURCE
Input files

See Also:
Constant Field Values

DESTINATION

public static final int DESTINATION
Ouput files

See Also:
Constant Field Values

FASTA_TYPE

public static final char FASTA_TYPE
FASTA format type

See Also:
Constant Field Values

MASE_TYPE

public static final char MASE_TYPE
MASE format type

See Also:
Constant Field Values

PHYLIP_TYPE

public static final char PHYLIP_TYPE
PHYLIP format type

See Also:
Constant Field Values

CLUSTAL_TYPE

public static final char CLUSTAL_TYPE
CLUSTAL format type

See Also:
Constant Field Values

FASTA_F

public static final java.lang.String FASTA_F
FASTA format name

See Also:
Constant Field Values

MASE_F

public static final java.lang.String MASE_F
MASE format name

See Also:
Constant Field Values

PHYLIPG_F

public static final java.lang.String PHYLIPG_F
PHYLIP GENERIC format name

See Also:
Constant Field Values

PHYLIPI_F

public static final java.lang.String PHYLIPI_F
PHYLIP INTERLEAVED format name

See Also:
Constant Field Values

PHYLIPS_F

public static final java.lang.String PHYLIPS_F
PHYLIP SEQUENTIAL format name

See Also:
Constant Field Values

CLUSTAL_F

public static final java.lang.String CLUSTAL_F
CLUSTAL format name

See Also:
Constant Field Values

DCSE_F

public static final java.lang.String DCSE_F
DCSE format name (discontinued). Only for ConTest.

See Also:
Constant Field Values

FILEFORMATS

public static final java.lang.String[] FILEFORMATS
Collection of format names. Expanded version.


CFILE_FORMATS

public static final java.lang.String[] CFILE_FORMATS
Collection of format names, only for ConTest. Shorter version.


PHYLIP_FTYPES

public static final java.lang.String[] PHYLIP_FTYPES
PHYLIP Format types for either Interleaved or Sequential: Classic/Extended

Constructor Detail

FileFormatConverter

public FileFormatConverter()
Initialize File Converter. No instantiation is performed.


FileFormatConverter

public FileFormatConverter(java.io.File file,
                           java.lang.String format,
                           int io)
Build file converter with file and format.

Parameters:
file - to read or write
format - file format
io - decide if these arguments are for read (input) or write (output) file. Values: SOURCE , DESTINATION.

FileFormatConverter

public FileFormatConverter(java.io.File fromfl,
                           java.lang.String fromfmt,
                           java.io.File tofl,
                           java.lang.String tofmt)
Build file converter with source and destination files.

Parameters:
fromfl - source file.
fromfmt - source file format.
tofl - destination file.
tofmt - destination file format.
Method Detail

convert

public boolean convert(java.io.File fromfl,
                       java.lang.String fromfmt,
                       java.io.File tofl,
                       java.lang.String tofmt)
Convert from file with format, to file with format.

Parameters:
fromfl - source file.
fromfmt - source file format.
tofl - destination file.
tofmt - destination file format.
Returns:
success when value is true; no success otherwise false

convert_totmp

public boolean convert_totmp(java.lang.String[] phy_options)
Creation of a temporary file, for phyml submission.

Temporary file must be of format Phylip (Interleaved or Sequential).

If source file, is of any other format convert to either Interleaved or Sequential according to user choice in phyml options. Else use same format.

Parameters:
phy_options - phyml options, choices made by the user. Used to know phylip type when input format is not phylip.
Returns:
success when value is true; no success otherwise false

getSequenceCount

public int getSequenceCount()
Get number of sequences, possibly if file loaded.

Returns:
number of sequences.

getSiteCount

public int getSiteCount()
Get number of sites, possibly if file loaded.

Returns:
number of sites.

setSiteCount

public void setSiteCount(int count)
Set number of sites to value of count.

Parameters:
count -

setSequenceCount

public void setSequenceCount(int count)
Set number of sequences to value of count.

Parameters:
count -

getSequences

public java.lang.String[][] getSequences()
Get sequences.

Returns:
sequences.

getTaxaNames

public java.lang.String[] getTaxaNames()
Get taxa names.

Returns:
taxaNames.

setSequences

public void setSequences(java.lang.String[][] msa)
Set sequences to msa value.

Parameters:
msa - sequences pass to file converter.

setTaxaNames

public void setTaxaNames(java.lang.String[] names)
Set taxa names to names value.

Parameters:
names - of taxa to pass to file converter.

setPhylipFormatType

public void setPhylipFormatType(java.lang.String type)
Use phylip format type in read/write phylip files.
  1. Classic - Taxa names limited to 10 characters maximum size.
  2. Extended - Taxa names have variable size.

Parameters:
type - values are Classic / Extended.
See Also:
PCLASSIC_F, PEXTENDED_F

readMSAfile

public boolean readMSAfile()
Read MSA file for instantiated source file and format.

Returns:
true when success; false, otherwise.

writeMSAFile

public void writeMSAFile()
Write to instantiated destination MSA file and format.


getMaxTaxaNameSize

public int getMaxTaxaNameSize(java.lang.String[] taxa)
Get maximum size for given taxa names.

Parameters:
taxa - array of taxa names.
Returns:
maximum size among given taxa names.