Post

2 followers Follow
0
Avatar

Can't list all the references via getNumberOfReferenceSequences() provided in the API

To do the Assembly, how could I get all the references?

 

I have a class extended from Assembler, and some code looks like:

public class test extends Assembler {
@Override
public String getUniqueId() {
return "test";
}

// the plugin named shown in the 'Map to Reference'
@Override
public String getName() {
return "test";
}

@Override
public ReferenceSequenceSupport getReferenceSequenceSupport() {
//return ReferenceSequenceSupport.SingleReferenceSequence;
return ReferenceSequenceSupport.MultipleReferenceSequences;
}

@Override
public ContigOutputSupport getContigOutputSupport() {
return ContigOutputSupport.ContigsOnly;
}

@Override
public boolean providesUnusedReads() {
return true;
}

// Ben: This will add an option on the "Map to Reference" window.
@Override
public Options getOptions(OperationLocationOptions locationOptions,
AssemblerInput.Properties inputProperties) {
return new test_testOptions();
}

// Before the assemble, split the reference first.
//


// This is actual function that enable 'Map to Reference'
@Override
public void assemble(Options _options, AssemblerInput assemblyInput,
ProgressListener progressListener,
Callback callback) throws DocumentOperationException {

test_options = (test_testOptions) _options;
boolean onlyAssembleHalf = options.isOnlyAssembleHalfOfTheReads();

CompositeProgressListener compositeProgressListener = new CompositeProgressListener(progressListener, 3);

compositeProgressListener.beginSubtask();

// Here, 0 means we only have only one ref in our dataset
final SequenceDocument referenceSequence = assemblyInput.getReferenceSequence(0, compositeProgressListener);

// how could we get the
System.out.println("Get how many refs: "+assemblyInput.toString());


// Ben debug
System.out.println("Number of ref sequences: "+assemblyInput.getNumberOfReferenceSequences());
System.out.println("Reference sequences: "+ assemblyInput.getReferenceSequence(0, progressListener).getSequenceString());

 

...

 

The output always be "Number of ref sequences: 1", but actually I have multiple reference for sure. So anyone can help to let me know why thus function does not work. 

 

Thanks!

arkilis

Please sign in to leave a comment.

7 comments

0
Avatar

What you are doing looks correct and it should return the correct number of reference sequences - at least it does when I just tried it now. Are you sure you actually choose multiple reference sequences in the assembly options when you run it. For example the reference sequence you select in the options should say something like Reference Sequence: "All 5 sequences from document name".

As a test, you could change your getReferenceSequenceSupport back to ReferenceSequenceSupport.SingleReferenceSequence and when you select multiple reference sequences in the options, Geneious should pop up a warning message saying "The selected assembler only supports a single reference sequence" and won't let you continue.

Hilary Miller 0 votes
Comment actions Permalink
0
Avatar

Yes, in light of your help, I found there is 'additional' option in the 'Map to Reference'. First you need to group all your reference sequences into a list. Then the functions are working.

arkilis 0 votes
Comment actions Permalink
0
Avatar

Just another related question.

 

How could I find out the 'Assembly Report'  type? It is a TextDocument object? Thanks

arkilis 0 votes
Comment actions Permalink
0
Avatar

It is a custom PluginDocument type which isn't available in the API. You can find out the class of any document by going to Tools->Preferences->Plugins and Features ->Customize Feature Set and turning on the 2 "Document Source..." viewers. The "Summary XML" view of any document lists the class name of the document at the start.

Why do you want to know about the 'assembly report' though? What are you trying to do with it?

Hilary Miller 0 votes
Comment actions Permalink
0
Avatar

Thanks for your quick reply. 

 

I was thinking to write a plugin which can save the Assembly Report as a text file. I tried the csv and tsv. It just looks like:

Created Date Description Modified Name Size
Wed Sep 11 10:33:30 EST 2013 Wed Sep 11 10:33:30 EST 2013 Assembly Report 42 KB

 

So if there is any way that enable us to save the whole Assembly Report content, which will be fantastic! Do you have any idea to do this?

 

Thanks again!

 

 

arkilis 0 votes
Comment actions Permalink
0
Avatar

Unfortunately with a custom viewer like that not really. You could write some code to obtain get the assembly report's DocumentViewerFactory and ask that to generate the JComponent it uses for viewing. But you are probably better off just selecting all the text from the viewer and using copy and paste to get it out of Geneious.

Hilary Miller 0 votes
Comment actions Permalink
0
Avatar

I might have try.

Appreciate your kind advice. It is very helpful!

arkilis 0 votes
Comment actions Permalink