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


Java Alignment类代码示例

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


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

示例1: BasicColourSampler

import dr.evolution.alignment.Alignment; //导入依赖的package包/类
public BasicColourSampler(Alignment tipColours, Tree tree) {

        if (tipColours.getSiteCount() != 1) {
            throw new IllegalArgumentException("Tip colour alignment must consist of a single column!");
        }

        nodeColours = new int[tree.getNodeCount()];
        colourCount = tipColours.getDataType().getStateCount();

        leafColourCounts = new int[colourCount];

        // initialize external node colours
        for (int i = 0; i < tree.getExternalNodeCount(); i++) {
            NodeRef node = tree.getExternalNode(i);
            int colour = tipColours.getState(tipColours.getTaxonIndex(tree.getTaxonId(i)), 0);
            nodeColours[node.getNumber()] = colour;
            leafColourCounts[colour]++;
        }

        nodePartials = new double[tree.getNodeCount()][colourCount];
    }
 
开发者ID:beast-dev,项目名称:beast-mcmc,代码行数:22,代码来源:BasicColourSampler.java

示例2: StructuredColourSampler

import dr.evolution.alignment.Alignment; //导入依赖的package包/类
public StructuredColourSampler(Alignment tipColours, Tree tree, boolean nodeBias, boolean branchBias, boolean secondIteration) {

        if (tipColours.getSiteCount() != 1) {
            throw new IllegalArgumentException("Tip colour alignment must consist of a single column!");
        }

        nodeColours = new int[tree.getNodeCount()];
        colourCount = tipColours.getDataType().getStateCount();

        leafColourCounts = new int[colourCount];
        // initialize external node colours
        for (int i = 0; i < tree.getExternalNodeCount(); i++) {
            NodeRef node = tree.getExternalNode(i);
            int colour = tipColours.getState(tipColours.getTaxonIndex(tree.getTaxonId(i)), 0);
            nodeColours[node.getNumber()] = colour;
            leafColourCounts[colour]++;
        }

        useNodeBias = nodeBias;
        useBranchBias = branchBias;
        useSecondColourIteration = secondIteration;

        initialize(tree);     // uses only tree constants (number of tips, etc)

    }
 
开发者ID:beast-dev,项目名称:beast-mcmc,代码行数:26,代码来源:StructuredColourSampler.java

示例3: isSegregating

import dr.evolution.alignment.Alignment; //导入依赖的package包/类
public static boolean isSegregating(Alignment a, int j, int[] counts) {
	for (int i = 0; i < counts.length; i++) {
		counts[i] = 0;
	}
	int seqCount = a.getSequenceCount();
	for (int i = 0; i < seqCount; i++) {
		int state = a.getState(i, j);
		if (state >= 0 && state < counts.length) {
			counts[a.getState(i, j)] += 1;
		}
	}
       for(int count : counts) {
           if( count > 0 && count < seqCount ) return true;
       }
	return false;
}
 
开发者ID:beast-dev,项目名称:beast-mcmc,代码行数:17,代码来源:SelectionMapping.java

示例4: initAlignment

import dr.evolution.alignment.Alignment; //导入依赖的package包/类
/**
 * Initializes the iAlignment array from the given alignment.
 */
private void initAlignment(Alignment alignment, int[] treeIndex) {
	
	int numSeqs = alignment.getSequenceCount();
	int numSites = alignment.getSiteCount();
	DataType dataType = alignment.getDataType();
	int numStates = dataType.getStateCount();
	
	iAlignment = new IntMathVec[numSites];
	
	int[] column = new int[numSeqs];
	for (int i =0; i < numSites; i++) {
		for (int j = 0; j < numSeqs; j++) {
			column[treeIndex[j]] = ((alignment.getState(j, i) >= numStates) ? 0 : 1);	
		}
		iAlignment[i] = new IntMathVec(column);
	}
}
 
开发者ID:beast-dev,项目名称:beast-mcmc,代码行数:21,代码来源:HomologyRecursion.java

示例5: initAlignment

import dr.evolution.alignment.Alignment; //导入依赖的package包/类
/**
 * Initializes the iAlignment array from the given alignment.
 */
private void initAlignment(Alignment alignment, int[] treeIndex) {

    int numSeqs = alignment.getSequenceCount();
    int numSites = alignment.getSiteCount();
    DataType dataType = alignment.getDataType();
    int numStates = dataType.getStateCount();

    iAlignment = new int[numSeqs][numSites];

    // populate alignment in order of tree
    for (int i = 0; i < numSeqs; i++) {
        for (int j = 0; j < numSites; j++) {
            iAlignment[treeIndex[i]][j] = alignment.getState(i, j);
        }
    }
}
 
开发者ID:beast-dev,项目名称:beast-mcmc,代码行数:20,代码来源:IstvanOperator.java

示例6: getPartialsForGroupSizeOne

import dr.evolution.alignment.Alignment; //导入依赖的package包/类
private void getPartialsForGroupSizeOne(Taxon tax, double[] tipPartials)
{
	Alignment aln = data.getAlignment();
	int sc = aln.getStateCount();
	int index = aln.getTaxonIndex(tax);
	int j=0;
	for(int i=0; i<aln.getSiteCount(); i++){
		int s = aln.getState(index, i);
		if(s>=sc){
			for(int k=0; k<sc; k++)
				tipPartials[j + k] = 1.0;
		}else
			System.arraycopy(internalMatrix, s*sc, tipPartials, j, sc);
		j += sc;
	}
}
 
开发者ID:beast-dev,项目名称:beast-mcmc,代码行数:17,代码来源:HiddenLinkageModel.java

示例7: simulateMsatPattern

import dr.evolution.alignment.Alignment; //导入依赖的package包/类
/**
 * Convert an alignment to a pattern
 */
public Patterns simulateMsatPattern(){
    Alignment align = simulate();

    int[] pattern = new int[align.getTaxonCount()];
    for(int i = 0; i < pattern.length; i++){
        String taxonName = align.getSequence(i).getTaxon().getId();
        int index = taxa.getTaxonIndex(taxonName);
        pattern[index] = Integer.parseInt(align.getSequence(i).getSequenceString());
    }
    Patterns patterns = new Patterns(dataType,taxa);
    patterns.addPattern(pattern);
    for(int i = 0; i < pattern.length;i++){
        System.out.print(pattern[i]+",");
    }
    System.out.println();
    
    return patterns;
}
 
开发者ID:whdc,项目名称:ieo-beast,代码行数:22,代码来源:MicrosatelliteSimulator.java

示例8: MetagenomeData

import dr.evolution.alignment.Alignment; //导入依赖的package包/类
public MetagenomeData(TaxonList taxa, Alignment alignment, LinkageConstraints constraints, boolean fixedReferenceTree)
{
	this.alignment = alignment;
	this.constraints = constraints;
	this.fixedReferenceTree = fixedReferenceTree;
	referenceTaxa = new Taxa(taxa.asList());
	if(fixedReferenceTree == true && !(taxa instanceof Tree)){
		throw new RuntimeException("Error, a tree must be provided in order to fix the topology of reference taxa");
	}
	reads = new Taxa();
	List<Taxon> alltaxa = alignment.asList();
	for(int i=0; i<alltaxa.size(); i++)
	{
		if(!referenceTaxa.contains(alltaxa.get(i)))
			reads.addTaxon(alltaxa.get(i));
	}
	if(constraints==null){
		this.constraints = new LinkageConstraints(new ArrayList<LinkedGroup>());
	}
}
 
开发者ID:beast-dev,项目名称:beast-mcmc,代码行数:21,代码来源:MetagenomeData.java

示例9: isSingleton

import dr.evolution.alignment.Alignment; //导入依赖的package包/类
public static boolean isSingleton(Alignment a, int j, int[] counts) {
	for (int i = 0; i < counts.length; i++) {
		counts[i] = 0;
	}
	for (int i = 0; i < a.getSequenceCount(); i++) {
		int state = a.getState(i, j);
		if (state >= 0 && state < counts.length) {
			counts[a.getState(i, j)] += 1;
		}
	}
       for(int count : counts) {
           if( count == 1 ) return true;
       }
	return false;
}
 
开发者ID:beast-dev,项目名称:beast-mcmc,代码行数:16,代码来源:SelectionMapping.java

示例10: readDataBlock

import dr.evolution.alignment.Alignment; //导入依赖的package包/类
/**
 * Reads a 'DATA' block.
 */
private Alignment readDataBlock(/*TaxonList taxonList*/) throws ImportException, IOException {

    taxonCount = 0;
    siteCount = 0;
    dataType = null;

    readDataBlockHeader("MATRIX", DATA_BLOCK);

    SimpleAlignment alignment = new SimpleAlignment();
    readSequenceData(alignment, null);
    alignment.updateSiteCount();

    findEndBlock();

    return alignment;
}
 
开发者ID:beast-dev,项目名称:beast-mcmc,代码行数:20,代码来源:NexusImporter.java

示例11: init

import dr.evolution.alignment.Alignment; //导入依赖的package包/类
public void init(Tree tree, Alignment alignment, SubstitutionModel substModel, 
	     double mutationRate, double lengthDistr, double deathRate) {
  
   	// initialize the iParent and iTau arrays based on the given tree.
initTree(tree, mutationRate);

int[] treeIndex = new int[tree.getTaxonCount()];
for (int i =0; i < treeIndex.length; i++) {
    treeIndex[i] = tree.getTaxonIndex(alignment.getTaxonId(i));
    //System.out.println("alignment[" + i + "] = tree[" + treeIndex[i] + "]");
}
  		
   	// initialize the iAlignment array from the given alignment.
   	initAlignment(alignment, treeIndex);
   	
   	// initialize the iSequences array from the given alignment.
   	initSequences(alignment, treeIndex);
   	
   	// initialize the iTrans array from the substitution model -- must be called after populating tree!
   	initSubstitutionModel(substModel);
   	
   	// iLambda, iMu
   	iLambda = deathRate*lengthDistr;
   	iMu = deathRate;
   	
   	// iNumNucs - alphabet size 
DataType dataType = substModel.getDataType();
   	iNumNucs = dataType.getStateCount();

// Initialise TKF91 coefficients in iB, iH, iN, iE, and iInitial
initTKF91();

// Check
checkConsistency();

// Initialise native method
iNativeMethod = new NativeTreeLikelihood();
iNativeMethod.init(iNumNucs, cMaxUnalignDimension, iParent, iEquil, iTrans, iSequences, iN, iH, iE, iB);

   }
 
开发者ID:beast-dev,项目名称:beast-mcmc,代码行数:41,代码来源:HomologyRecursion.java

示例12: parseXMLObject

import dr.evolution.alignment.Alignment; //导入依赖的package包/类
public Object parseXMLObject(XMLObject xo) throws XMLParseException {

        Alignment alignment = (Alignment)xo.getChild(Alignment.class);

        if (alignment.getDataType().getType() != DataType.NUCLEOTIDES) {
            throw new XMLParseException("HypermutantAlignment can only convert nucleotide alignments");
        }

        String typeName = xo.getStringAttribute(CONTEXT_TYPE);
        HypermutantAlignment.APOBECType type = null;
        try {
            type = HypermutantAlignment.APOBECType.valueOf(typeName.toUpperCase());
        } catch(IllegalArgumentException iae) {
            throw new XMLParseException("Unrecognised hypermutation type: " + typeName);
        }

        HypermutantAlignment convert = new HypermutantAlignment(type, alignment);
        int mutatedCount = convert.getMutatedContextCount();
        int totalCount = mutatedCount + convert.getUnmutatedContextCount();

        Logger.getLogger("dr.evoxml").info("Converted alignment, '" + xo.getId() + "' to a hypermutant alignment targeting " + type.toString() + " contexts.\r" +
                "\tPotentially mutated contexts: " + mutatedCount + " out of a total of " + totalCount + " contexts");

        return convert;
    }
 
开发者ID:beast-dev,项目名称:beast-mcmc,代码行数:26,代码来源:HypermutantAlignmentParser.java

示例13: importBEAST

import dr.evolution.alignment.Alignment; //导入依赖的package包/类
public void importBEAST(List<TaxonList> taxonLists, List<Alignment> alignments) throws Importer.ImportException {

        TaxonList taxa = null;

        List children = root.getChildren();
        for(Object aChildren : children) {
            Element child = (Element) aChildren;

            if( child.getName().equalsIgnoreCase(TaxaParser.TAXA) ) {
                if( taxa == null ) {
                    taxa = readTaxa(null, child);
                    taxonLists.add(taxa);
                } else {
                    taxonLists.add(readTaxa(taxa, child));
                }
            } else if( child.getName().equalsIgnoreCase(AlignmentParser.ALIGNMENT) ) {
                if( taxa == null ) {
                    throw new Importer.ImportException("taxa not defined");
                }
                alignments.add(readAlignment(child, taxa));
            }
        }
    }
 
开发者ID:beast-dev,项目名称:beast-mcmc,代码行数:24,代码来源:BeastImporter.java

示例14: generateRecombinant

import dr.evolution.alignment.Alignment; //导入依赖的package包/类
private String generateRecombinant(final Node node, final Map<Node, Taxon> nodeMap, final Alignment alignment) {
    String seq = node.getSequence();

    if (seq == null) {
        // if the sequence hasn't already been cached, then construct it...
        if (node.getParent1() == null && node.getParent2() == null) {
            // no parents so must have a sequence
            Taxon taxon = nodeMap.get(node);
            int index = alignment.getTaxonIndex(taxon);
            Sequence sequence = alignment.getSequence(index);
            seq = sequence.getSequenceString();
        } else {
            String part1 = generateRecombinant(node.getParent1(), nodeMap, alignment);
            String part2 = generateRecombinant(node.getParent2(), nodeMap, alignment);

            int breakPoint = node.getBreakPoint();

            seq = part1.substring(0, breakPoint) + part2.substring(breakPoint);
        }

        // cache the sequence
        node.setSequence(seq);
    }

    return seq;
}
 
开发者ID:beast-dev,项目名称:beast-mcmc,代码行数:27,代码来源:RecomboGen.java

示例15: writeAlignments

import dr.evolution.alignment.Alignment; //导入依赖的package包/类
/**
 * Write all Alignments
 * @param writer  XMLWriter
 */
public void writeAlignments(List<Alignment> alignments, XMLWriter writer) {
    int index = 1;
    for (Alignment alignment : alignments) {
        if (alignments.size() > 1) {
            //if (!options.allowDifferentTaxa) {
            alignment.setId(AlignmentParser.ALIGNMENT + index);
            //} else { // e.g. alignment_gene1
            // alignment.setId("alignment_" + mulitTaxaTagName + index);
            //}
        } else {
            alignment.setId(AlignmentParser.ALIGNMENT);
        }
        writeAlignment(alignment, writer);
        index += 1;
        writer.writeText("");
    }

}
 
开发者ID:beast-dev,项目名称:beast-mcmc,代码行数:23,代码来源:AlignmentGenerator.java


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