[Biojava-l] Location output

Thomas Down td2 at sanger.ac.uk
Thu Apr 14 08:16:43 EDT 2005


On 14 Apr 2005, at 11:58, mmatilai at hytti.uku.fi wrote:

> Hi!
>
> I have added features to a sequence file using 
> StrandedFeature.Template as a
> template and RangeLocation class to define the locations. The sequence 
> is saved
> in Genbank format after the addition of all features. I want to output 
> the
> features later to a text file and this is how they look (type and 
> location shown):
>
> ER9_rc	[15276,15296]
>
> I would like to get rid of the [] brackets.
>
> I modified the toString method of the RangeLocation class and removed 
> these
> brackets but after this I get an error message as the program tries to 
> write the
> features added to the genbank file using GenbankFormat class method
> writeSequence. Does anyone have an explanation to this? Or a simple 
> solution how
> I can simplify my text file output to leave out the brackets?

Hi,

In general, it's not a good idea to rely on "toString" methods 
returning any particular format -- they're really for debugging 
purposes, rather than day to day uses.  The best solution here is to 
use code like:

          Feature f = ...;
          System.out.println(
                   f.getType() + "\t" +
                   f.getLocation().getMin() + "," +
                   f.getLocation().getMax()
          );

This approach means you can have exactly the output format you want, 
and insulates you from any future changes to toString methods.

I am, however, worried about why GenbankFormat is giving you an error 
-- it shouldn't be relying on toString methods at all.  Could you send 
me a copy of the error stack trace?

Thanks,

         Thomas.



More information about the Biojava-l mailing list