[Biojava-l] nested features

Martina boehme at mpiib-berlin.mpg.de
Wed May 18 06:07:54 EDT 2005


Hi,
I'm still having problems with nested features. I know that the order 
in which they are retrieved is not constant, but the hierachy should 
be. I do:

delete(db, "AF100928");
create(db, sequence);
retrieveSeq(db, "AF100928");

and get:

deleting AF100928
adding a sequence
1
retrieving AF100928
AF100928 contains 2 features
Source: 1 Type: AIF-1 contains: 0
Project : [2572/73, A]
Source: ncbi Type: gen contains: 8
Second Level: Source: AIF Type: siRNA contains: 0
Second Level: Source: AIF 5`450 / AIF 3`682 Type: Amplicon contains: 0
Second Level: Source: AIF Type: siRNA contains: 0
Second Level: Source: AIF 5`450 / AIF 3`682 Type: Amplicon contains: 0
Second Level: Source: AIF Type: siRNA contains: 0
Second Level: Source: AIF 5`450 / AIF 3`682 Type: Amplicon contains: 0
Second Level: Source: AIF Type: siRNA contains: 0
Second Level: Source: AIF 5`450 / AIF 3`682 Type: Amplicon contains: 0


OR, on some runs (at least one in 10) I get:

deleting AF100928
adding a sequence
1
retrieving AF100928
AF100928 contains 1 features
Source: ncbi Type: gen contains: 2
Second Level: Source: AIF Type: siRNA contains: 1
Second Level: Source: AIF 5`450 / AIF 3`682 Type: Amplicon contains: 0

I can't see any difference in the biosql db (MySql), but I don't know 
where to look exactly.
If I don't delete the record, just retrieve it on different runs, the 
output stays the same. I'm using biojava live from last month.
I would be very grateful if someone could help me with this!

Martina

I add it like this:

private static void create(BioSQLSequenceDB db, String sequence)
			throws IllegalSymbolException, IllegalArgumentException, 
ChangeVetoException, IndexOutOfBoundsException, BioException {
		Sequence seq = DNATools.createDNASequence(sequence, "AF100928");
		// add annotation
		seq.getAnnotation().setProperty("Lab-Genname", "AIF");
		seq.getAnnotation().setProperty("gi", "4323586");
		seq.getAnnotation()
				.setProperty("genename", "apoptosis-inducing factor");
		seq.getAnnotation().setProperty("organism", "Homo sapiens");
		seq.getAnnotation().setProperty("protein-id", "AAD16436.1");
		// fill the template
		Feature.Template templSeq = new Feature.Template();
		templSeq.source = "ncbi";
		// templSeq.strand = StrandedFeature.UNKNOWN;
		templSeq.type = "gen";
		templSeq.location = Location.empty;
		Feature seqF = seq.createFeature(templSeq);
		// create siRNA
		StrandedFeature.Template templSt = new StrandedFeature.Template();
		templSt.location = new RangeLocation(201, 221);
		templSt.strand = StrandedFeature.POSITIVE;
		templSt.source = "AIF"; // =>id
		templSt.type = "siRNA"; // oder shRNA oder cellline?
		Annotation annoSiRNA = new SimpleAnnotation();
		annoSiRNA.setProperty("abbreviation", "AIF");
		annoSiRNA.setProperty("no", 3);
		templSt.annotation = annoSiRNA;
		Feature sf = seqF.createFeature(templSt);
		// create charge
		Feature.Template charge = new Feature.Template();
		charge.type = "AIF-1";
		charge.source = "1"; // Erste Synthese
		charge.location = Location.empty;
		Annotation chargeAnno = new SmallAnnotation();
		chargeAnno.setProperty("Batchno", "2572/73");
		chargeAnno.setProperty("Project", "A");
		charge.annotation = chargeAnno;
		Feature cf = sf.createFeature(charge);
		// create Amplicon
		StrandedFeature.Template templ = new StrandedFeature.Template();
		templ.location = new RangeLocation(72, 92);
		templ.source = "AIF 5`450 / AIF 3`682";
		templ.type = "Amplicon";
		templ.strand = StrandedFeature.UNKNOWN;
		Annotation annoAmplicon = new SimpleAnnotation();
		annoAmplicon.setProperty("Provider", "Invitrogen");
		annoAmplicon.setProperty("designed by", "Chris");
		annoAmplicon.setProperty("Stock-Box/Position", "rtS-A3/A5 + rtS-A3/A6");
		annoAmplicon.setProperty("Arbeitslösung", "rtArb-A1/C3");
		// templ.annotation = annoAmplicon;
		Feature af = seqF.createFeature(templ);

		System.out.println("adding a sequence");
		System.out.println(seq.countFeatures());
		db.addSequence(seq);
	}

and here it gets printed:

private static void retrieveSeq(BioSQLSequenceDB db, String seqName)
throws BioException, NoSuchElementException {
Sequence seq;
System.out.println("retrieving " + seqName);
seq = db.getSequence(seqName);
System.out.println(seq.getName() + " contains " + seq.countFeatures() 
+ " features");
for (Iterator<Feature> i = seq.features(); i.hasNext();) {
	Feature f = (Feature) i.next();
	System.out.println("Source: " + f.getSource() + " Type: " + 
f.getType() + " contains: " + f.countFeatures());
	Annotation anno = f.getAnnotation();
	// print each key value pair
	for (Iterator it = anno.keys().iterator(); it.hasNext();) {
		Object key = it.next();
		System.out.println(key + " : " + anno.getProperty(key));
	}
	for (Iterator<Feature> it = f.features(); it.hasNext();) {
		Feature fs = (Feature) it.next();
		System.out.println("Second Level: Source: " + fs.getSource()
				+ " Type: " + fs.getType() + " contains: "
				+ fs.countFeatures());
	}
}


More information about the Biojava-l mailing list