Post

2 followers Follow
0
Avatar

Options for consensus

I'm trying to set a threshold 100 Identical and IgnoreGapsfor geerating a Consensus sequence using this code:

 DocumentOperation generate_consensus_operation = PluginUtilities.getDocumentOperation("Generate_Consensus");
ConsensusOptions consensusOptions=new ConsensusOptions();//true,true,false/*the aligment has no reference sequence*/);// ConsensusOptions var3 = new ConsensusOptions(true, var1.isFreeEndGapAlignment(), SequenceAlignmentDocument.getContigReferenceSequenceIndex() >= 0); the third false is needed otherwise we get Calling consensus on an alignment with no reference sequence using reference options.
consensusOptions.setValue("noConsensusGaps",Boolean.valueOf(true));
//consensusOptions.setValue("noConsensusEndGaps",Boolean.valueOf(true));
consensusOptions.getOption("noConsensusEndGaps").setValue(Boolean.valueOf(true));
//consensusOptions.getOption("noConsensusEndGaps").setValue(Boolean.valueOf(true));
// consensusOptions.setValue("noConsensusGaps", Boolean.valueOf(true));
//consensusOptions.setValue("noConsensusEndGaps",Boolean.valueOf(true));

List<AnnotatedPluginDocument> newAnnotatedPluginDocuments=generate_consensus_operation.performOperation(ProgressListener.EMPTY, consensusOptions, copyOfAnnotatedPluginDocument );
PluginDocument documentOrCrash = newAnnotatedPluginDocuments.get(0).getDocumentOrCrash();
System.out.println("GENERATED CONSENSUS WITH OPTIONS:"+((SequenceDocument) documentOrCrash).getSequenceString());
return newAnnotatedPluginDocuments.get(0);

 

The resulting consensus puts N in places where I have a Nucleotide and a gap when using a pairwise alignment.

It should be the nucleotide.

As one could seee from the code I attempted many variations but none worked so far.

Thank you

Adrian

Please sign in to leave a comment.

2 comments

0
Avatar

The consensus options are a bit fiddly. You shouldn't construct them directly because they are not in the public API and to solve your problem you can pass the alignment into the getOptions method. This should do it:

DocumentOperation generate_consensus_operation = PluginUtilities.getDocumentOperation("Generate_Consensus");
Options consensusOptions = generate_consensus_operation.getOptions(copyOfAnnotatedPluginDocument);

if (!consensusOptions.setValue("thresholdPercent", "100")) {
throw new DocumentOperationException("Failed to set threshold");
}
if (!consensusOptions.setValue("noConsensusGaps", Boolean.TRUE)) {
throw new DocumentOperationException("Failed to set ignore gaps");
}

List<AnnotatedPluginDocument> newAnnotatedPluginDocuments=generate_consensus_operation.performOperation(ProgressListener.EMPTY, consensusOptions, copyOfAnnotatedPluginDocument);
PluginDocument documentOrCrash = newAnnotatedPluginDocuments.get(0).getDocumentOrCrash();
System.out.println("GENERATED CONSENSUS WITH OPTIONS:"+((SequenceDocument) documentOrCrash).getSequenceString());
return newAnnotatedPluginDocuments.get(0);
Richard Moir 0 votes
Comment actions Permalink