1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
|
/*
* This file is part of ALTER.
*
* ALTER is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ALTER is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ALTER. If not, see <http://www.gnu.org/licenses/>.
*/
package writer;
import java.util.logging.Level;
import types.MSA;
import types.Protein;
import types.Type;
import types.Typeable;
/**
* Extends class MsfWriter to adapt the output to jModelTest.
* @author Daniel Gomez Blanco
* @version 1.0
*/
public class MsfJModelTestWriter extends MsfWriter
{
/**
* Class constructor. Calls the superclass constructor.
* @param os Output operating system.
* @param lowerCase Lowercase output.
* @param logger Logger name.
*/
public MsfJModelTestWriter(String os, boolean lowerCase, String logger)
{
super(os,lowerCase,logger);
}
/**
* Writes a MSA in MSF format, adapted for jModelTest. It checks
* that the MSA is not a protein MSA and that it contains 4 or more sequences.
* It then calls the method in the superclass.
* @param msa Input MSA.
* @return String with the MSA in MSF format.
*/
@Override
public String write(MSA msa)
{
if (msa.getSeqs().size() < 4)
logger.log(Level.WARNING, "MSA contains less than 4 sequences. " +
"It will not be processed by jModelTest.");
Type type = null;
if (msa instanceof Typeable)
type = ((Typeable) msa).getType();
if (type == null)
{
type = WriterUtils.inferType(msa);
}
if (type instanceof Protein)
{
logger.log(Level.WARNING,"MSA is an amino acids MSA. " +
"It will not be processed by jModelTest (only DNA is processed).");
}
return super.write(msa);
}
}
|