当前位置: 首页>>代码示例>>Java>>正文


Java Alignment类代码示例

本文整理汇总了Java中pal.alignment.Alignment的典型用法代码示例。如果您正苦于以下问题:Java Alignment类的具体用法?Java Alignment怎么用?Java Alignment使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Alignment类属于pal.alignment包,在下文中一共展示了Alignment类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: calculateInvariableSites

import pal.alignment.Alignment; //导入依赖的package包/类
/**
 * Calculate invariable sites.
 * 
 * @param alignment the alignment
 * 
 * @return the invariable sites in the alignment
 */
public static int calculateInvariableSites (Alignment alignment) {

	//use this function to estimate a good starting value for the InvariableSites distribution.
	int numSites    = alignment.getSiteCount();
	int numSeqs     = alignment.getSequenceCount();
	int inv         = 0;
	int tmp;
	boolean tmpInv = true;
	for(int i=0; i < numSites; i++) {
		tmp     = indexOfChar(alignment.getData(0,i));
		tmpInv  = true;
		for(int j=0; j < numSeqs; j++) {
			if(indexOfChar(alignment.getData(j,i)) != tmp) { //if at least one difference in column i:
				j = numSeqs;    //we exit this for.
				tmpInv = false; //i is not an invariable site.
			}
		}
		if(tmpInv)
			inv++;
	}
	return inv;
}
 
开发者ID:ddarriba,项目名称:jmodeltest2,代码行数:30,代码来源:Utilities.java

示例2: createModel

import pal.alignment.Alignment; //导入依赖的package包/类
/**
 * Creates a new ProtTest object.
 * 
 * @param matrix the matrix
 * @param distribution the distribution
 * @param modelProperties the model APPLICATION_PROPERTIES
 * 
 * @return the model
 */
public Model createModel(String matrix, int distribution, Properties modelProperties,
        Alignment alignment, Tree tree, int ncat) {
    Model model = null;
    boolean plusF;
    if (modelProperties != null) {
        plusF = Boolean.parseBoolean(
                modelProperties.getProperty(
                AminoAcidModel.PROP_PLUS_F, "false"));
    } else {
        plusF = false;
    }
    switch (sort) {
        case PROTEIC:
            model = new AminoAcidModel(matrix, distribution, plusF,
                    alignment, tree, ncat);
            break;
        case NUCLEIC:
            throw new ProtTestInternalException("Unsupported operation: nucleic data");
    }
    return model;
}
 
开发者ID:ddarriba,项目名称:prottest3,代码行数:31,代码来源:ProtTestFactory.java

示例3: getFrequencies

import pal.alignment.Alignment; //导入依赖的package包/类
/**
 * Gets the frequencies.
 * 
 * @param alignment
 *            the alignment
 * 
 * @return the frequencies
 */
public static double[] getFrequencies(Alignment alignment) {
	int numSites = alignment.getSiteCount();
	int numSeqs = alignment.getSequenceCount();
	double freqs[] = new double[AMINOACID_NUM_STATES];
	int aas[] = new int[AMINOACID_NUM_STATES];
	int total_aas = 0;
	for (int i = 0; i < AMINOACID_NUM_STATES; i++)
		aas[i] = 0;

	for (int i = 0; i < numSites; i++)
		for (int j = 0; j < numSeqs; j++) {
			int index = indexOfChar(alignment.getData(j, i));
			if (index >= 0) {
				aas[index]++;
				total_aas++;
			}
		}

	for (int i = 0; i < AMINOACID_NUM_STATES; i++)
		freqs[i] = (double) aas[i] / (double) total_aas;

	return freqs;
}
 
开发者ID:ddarriba,项目名称:prottest3,代码行数:32,代码来源:ProtTestAlignment.java

示例4: addModelCartesian

import pal.alignment.Alignment; //导入依赖的package包/类
/**
 * Adds the models result of combine each matrix with each distribution.
 * There will be MxD new models in the iterator, where
 * M is the number of matrices
 * D is the number of distributions
 *
 * @param matrices collection of all the substitution matrices
 * @param distributions collection of all the distributions
 * @param modelProperties the model properties
 *
 * @return true, if successfully added all models
 */
public boolean addModelCartesian(Collection<String> matrices, Collection<Integer> distributions,
        Properties modelProperties, Alignment alignment, Tree tree, int ncat) {
    boolean allDone = true;
    boolean plusF = Boolean.parseBoolean(
            modelProperties.getProperty(
            Model.PROP_PLUS_F, "false"));
    Properties modelPropertiesFalse = new Properties();
    Properties modelPropertiesTrue = new Properties();
    modelPropertiesFalse.setProperty(Model.PROP_PLUS_F, "false");
    modelPropertiesTrue.setProperty(Model.PROP_PLUS_F, "true");
    for (String matrix : matrices) {
        for (Integer distribution : distributions) {
            allDone &= addModel(matrix, distribution, modelPropertiesFalse,
                    alignment, tree, ncat);
            if (plusF) {
                allDone &= addModel(matrix, distribution, modelPropertiesTrue,
                        alignment, tree, ncat);
            }
        }
    }
    return allDone;
}
 
开发者ID:ddarriba,项目名称:prottest3,代码行数:35,代码来源:ModelCollection.java

示例5: TemporaryFileManager

import pal.alignment.Alignment; //导入依赖的package包/类
/**
 * Instantiates a new temporary file manager.
 * 
 * @param path the path
 * @param alignment the alignment
 * @param tree the tree
 * @param poolSize the pool size
 */
private TemporaryFileManager(Alignment alignment, Tree tree, int poolSize) {
	
	alignmentTempFile = new File[poolSize];
	logTempFile = new File[poolSize];
	this.alignment = alignment;
	this.tree = tree;

	try {
	    for (int i = 0; i < poolSize; i++) {
	    	alignmentTempFile[i] = File.createTempFile(BASE_ALIGNMENT_FILE_NAME, null);
	    	alignmentTempFile[i].deleteOnExit();
	    	logTempFile[i] = File.createTempFile(BASE_LOG_FILE_NAME, null);
	    	logTempFile[i].deleteOnExit();
	        convertAlignment(alignment, alignmentTempFile[i]);
        }
	    treeTempFile = File.createTempFile(BASE_TREE_FILE_NAME, null);
	    treeTempFile.deleteOnExit();
	    if (tree != null)
        	convertTree(tree, treeTempFile);
	} catch (IOException e) {
		throw new ProtTestInternalException("Cannot create temporary files");
	}
    ThreadPoolSynchronizer.synchronize(poolSize);
    synchronizer = ThreadPoolSynchronizer.getInstance();
}
 
开发者ID:ddarriba,项目名称:prottest3,代码行数:34,代码来源:TemporaryFileManager.java

示例6: Consensus

import pal.alignment.Alignment; //导入依赖的package包/类
/** Creates new form Consensus */
public Consensus(XProtTestView mainFrame, TreeFacade facade,
		Model[] models, Alignment alignment) {
	initComponents();
	this.mainFrame = mainFrame;
	this.facade = facade;
	this.models = new SingleModelCollection(models, alignment);
	this.displayWriter = new PrintWriter(new TextAreaWriter(displayArea));
	this.logHandler = getDefaultLogger().addHandler(displayWriter,
			Level.OFF);

	resourceMap = Application
			.getInstance(es.uvigo.darwin.xprottest.XProtTestApp.class)
			.getContext().getResourceMap(Consensus.class);

	Font f = new Font(Font.MONOSPACED, Font.PLAIN, 12);
	displayArea.setFont(f);
}
 
开发者ID:ddarriba,项目名称:prottest3,代码行数:19,代码来源:Consensus.java

示例7: setAlignment

import pal.alignment.Alignment; //导入依赖的package包/类
public void setAlignment(Alignment alignment) {
	this.alignment = alignment;
	setNumTaxa(alignment.getSequenceCount());
	setNumSites(alignment.getSiteCount());
	setNumBranches(2 * numTaxa - 3);
	setNumInvariableSites(Utilities.calculateInvariableSites(alignment));

	DataType dt = alignment.getDataType();
	// check ambiguity
	isAmbiguous = false;
	if (alignment.getDataType().isAmbiguous()) {
		isAmbiguous = true;
	} else {
		for (int i = 0; i < numTaxa; i++) {
			String seq = alignment.getAlignedSequenceString(i);
			if (seq.indexOf(Alignment.GAP) >= 0) {
				isAmbiguous = true;
				break;
			}
			for (int j = 0; j < seq.length(); j++) {
				if (dt.getState(seq.charAt(j)) == AMBIGUOUS_DATATYPE_STATE) {
					isAmbiguous = true;
					break;
				}
			}
		}
	}
}
 
开发者ID:ddarriba,项目名称:jmodeltest2,代码行数:29,代码来源:ApplicationOptions.java

示例8: createAlignment

import pal.alignment.Alignment; //导入依赖的package包/类
/**
 * Creates an alignment instance.
 * 
 * @param out
 *            the out
 * @param pr
 *            the pushback reader which contains the alignment
 * @param debug
 *            the debug state
 * 
 * @return the alignment
 * 
 * @throws AlignmentParseException
 *             the alignment parse exception
 * @throws IOException
 *             Signals that an I/O exception has occured.
 */
public static Alignment createAlignment(PrintWriter out, PushbackReader pr,
		boolean debug) throws AlignmentParseException, IOException {

	if (debug) {
		out.println("");
		out.println("**********************************************************");
		out.println("  Reading alignment...");
	}
	Alignment alignment = null;
	try {
		alignment = new ReadAlignment(pr);
	} catch (pal.alignment.AlignmentParseException e) {
		throw new AlignmentParseException(e.getMessage());
	}

	List<String> seqNames = new ArrayList<String>(
			alignment.getSequenceCount());
	for (int i = 0; i < alignment.getSequenceCount(); i++) {
		seqNames.add(alignment.getIdentifier(i).getName());
	}
	
	if (debug) {
		for (int i = 0; i < alignment.getSequenceCount(); i++) {
			out.println("    Sequence #" + (i + 1) + ": "
					+ alignment.getIdentifier(i).getName());
		}
		out.println("   Alignment contains " + alignment.getSequenceCount()
				+ " sequences of length " + alignment.getSiteCount());
		out.println("");
		out.println("**********************************************************");
		out.println("");
	}

	return alignment;
}
 
开发者ID:ddarriba,项目名称:jmodeltest2,代码行数:53,代码来源:AlignmentReader.java

示例9: AminoAcidModel

import pal.alignment.Alignment; //导入依赖的package包/类
/**
 * Instantiates a new amino acid substitution model.
 * 
 * @param matrix the matrix name
 * @param distribution the distribution value
 * @param plusF consider observed frequencies
 */
public AminoAcidModel(String matrix, int distribution, boolean plusF, 
		Alignment alignment, Tree tree, int ncat) {
	super(matrix, distribution, plusF, alignment, tree, ncat);
	
	if (isPlusF())
    	frequenciesDistribution = FREQ_DISTRIBUTION_EMPIRICAL;
    else
    	frequenciesDistribution = FREQ_DISTRIBUTION_OTHER;
}
 
开发者ID:ddarriba,项目名称:prottest3,代码行数:17,代码来源:AminoAcidModel.java

示例10: setAlignment

import pal.alignment.Alignment; //导入依赖的package包/类
/**
 * Sets the alignment only if there wasn't set or it is a different instance of the same object.
 * 
 * @param alignment the new alignment
 */
public void setAlignment(Alignment alignment) {
    if (this.alignment != 0 && this.alignment != alignment.toString().hashCode()) {
        throw new ProtTestInternalException("cannot set a different alignment");
    }
    this.alignment = alignment.toString().hashCode();
    this.numberOfSequences = alignment.getSequenceCount();
}
 
开发者ID:ddarriba,项目名称:prottest3,代码行数:13,代码来源:Model.java

示例11: checkAlignment

import pal.alignment.Alignment; //导入依赖的package包/类
/**
 * Checks if an alignment matches the internal model alignment
 * 
 * @return alignment equality
 */
public boolean checkAlignment(Alignment alignment) {
    if (alignment == null) {
        return false;
    }
    return (this.alignment == alignment.toString().hashCode() &&
            this.numberOfSequences == alignment.getSequenceCount());
}
 
开发者ID:ddarriba,项目名称:prottest3,代码行数:13,代码来源:Model.java

示例12: Model

import pal.alignment.Alignment; //导入依赖的package包/类
/**
     * Instantiates a new substitution model.
     * 
     * @param matrix the matrix name
     * @param distribution the distribution value
     * @param plusF consider observed frequencies
     * @param alignment the alignment
     * @param tree the tree
     * @param ncat the ncat
     */
    public Model(String matrix, int distribution, boolean plusF, Alignment alignment, Tree tree, int ncat) {

        if (distribution < 0 || distribution > 3) {
            throw new ProtTestInternalException("Distribution not supported " + distribution);
        }

        if (alignment == null) {
            throw new ProtTestInternalException("Null alignment");
        }

        this.matrix = matrix;
        this.distribution = distribution;
        this.plusF = plusF;
        this.alignment = alignment.toString().hashCode();
        this.numberOfSequences = alignment.getSequenceCount();
        this.tree = tree;
        this.lkState = new ModelEmptyLkState();

//		numBranches = 2*alignment.getSequenceCount() - 3;
        switch (distribution) {
            case DISTRIBUTION_UNIFORM:
                numOfTransCategories = 1;
                break;
            case DISTRIBUTION_INVARIABLE:
                numOfTransCategories = 1;
                break;
            case DISTRIBUTION_GAMMA:
                numOfTransCategories = ncat;
                break;
            case DISTRIBUTION_GAMMA_INV:
                numOfTransCategories = ncat;
                break;
            }

    }
 
开发者ID:ddarriba,项目名称:prottest3,代码行数:46,代码来源:Model.java

示例13: readAlignment

import pal.alignment.Alignment; //导入依赖的package包/类
public Alignment readAlignment(String filename, boolean debug)
        throws AlignmentParseException, FileNotFoundException, IOException {

    StringWriter sw = new StringWriter();
    Alignment alignment = AlignmentReader.readAlignment(new PrintWriter(sw), filename, debug);
    
    sw.flush();
    ProtTestLogger.getDefaultLogger().infoln(sw.toString());
    
    return alignment;
}
 
开发者ID:ddarriba,项目名称:prottest3,代码行数:12,代码来源:ProtTestFacadeImpl.java

示例14: computeInformationCriterion

import pal.alignment.Alignment; //导入依赖的package包/类
public SelectionChunk computeInformationCriterion(Alignment alignment, Model[] models,
        int criterion,
        double confidenceInterval) {

    ModelCollection modelCollection = new SingleModelCollection(models, alignment);

    InformationCriterion informationCriterion;

    double calculatedSampleSize = ProtTestAlignment.calculateSampleSize(alignment);

    switch (criterion) {
        case AIC:
            informationCriterion = new AIC(modelCollection, confidenceInterval, calculatedSampleSize);
            break;
        case BIC:
            informationCriterion = new BIC(modelCollection, confidenceInterval, calculatedSampleSize);
            break;
        case AICC:
            informationCriterion = new AICc(modelCollection, confidenceInterval, calculatedSampleSize);
            break;
        case DT:
            informationCriterion = new DT(modelCollection, confidenceInterval, calculatedSampleSize);
            break;
        case LNL:
            informationCriterion = new LNL(modelCollection, confidenceInterval, calculatedSampleSize);
            break;
        default:
            throw new ProtTestInternalException("Unexistent information criterion");
    }

    return new SelectionChunk(informationCriterion);

}
 
开发者ID:ddarriba,项目名称:prottest3,代码行数:34,代码来源:ProtTestFacadeImpl.java

示例15: ProtTestParameterVO

import pal.alignment.Alignment; //导入依赖的package包/类
/**
 * Instantiates a new ProtTestParameterVO.
 * 
 * @param alignmentFilePath the path of the file which contains the alignment
 * @param alignment the alignment
 * @param treeFilePath the path of the file which contains the starting topology, if exists
 * @param matrices the matrices of the models to optimize
 * @param distributions the distributions of the models to optimize
 * @param plusF boolean value to consider or not the empirical amino-acid frequencies
 * @param ncat the number of transition categories. It is only useful if the distribution is gamma
 * @param strategyMode the starting topology strategy mode
 */
public ProtTestParameterVO(String alignmentFilePath, Alignment alignment, String treeFilePath,
        Collection<String> matrices, Collection<String> distributions, boolean plusF,
        int ncat, int strategyMode) {
    this.alignmentFilePath = alignmentFilePath;
    this.alignment = alignment;
    this.treeFilePath = treeFilePath;
    this.matrices = matrices;
    this.distributions = distributions;
    this.plusF = plusF;
    this.ncat = ncat;
    this.strategyMode = strategyMode;
}
 
开发者ID:ddarriba,项目名称:prottest3,代码行数:25,代码来源:ProtTestParameterVO.java


注:本文中的pal.alignment.Alignment类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。