protected void processGeneOrDomain(String gene, String domain,
String property, String codonStart)
{
+ boolean domainEnd = "domainend".equalsIgnoreCase(property);
+
/*
- * If we have been processing a Gene or Domain, and this does not continue
- * it, then close it off (generate sequence features for it)
+ * If we have been processing a Domain or Gene, and this does not continue
+ * it, then close it off (generate sequence features for it). Do Domain
+ * first as it is in the context of the enclosing gene if any.
*/
- if (this.currentGene != null && !this.currentGene.equals(gene))
- {
- createFeature(GENE, currentGene, geneStart);
- }
if (this.currentDomain != null)
{
- if (!this.currentDomain.equals(domain)
- || "domainend".equalsIgnoreCase(property))
+ if (!this.currentDomain.equals(domain) || domainEnd)
{
- createFeature(DOMAIN, currentDomain, domainStart);
+ String description = currentDomain
+ + (currentGene == null ? "" : " (" + currentGene + ")");
+ createFeature(DOMAIN, description, domainStart);
}
}
+ if (this.currentGene != null && !this.currentGene.equals(gene))
+ {
+ createFeature(GENE, currentGene, geneStart);
+ }
/*
* and if we have declared a Gene or Domain which does not continue the
}
currentGene = gene;
- currentDomain = domain;
+ currentDomain = domainEnd ? null : domain;
}
/**
for (SequenceI seq : seqs) {
SequenceFeature[] sfs = seq.getSequenceFeatures();
// features are added in the order in which their end is found
- // (Gene before Domain when they end together)
+ // (Domain before Gene when they end together)
assertEquals(5, sfs.length);
// TODO settle which way round type/description go!
- assertEquals("Exon1", sfs[0].type);
+ assertEquals("Exon1 (Adh)", sfs[0].type);
assertEquals("Domain", sfs[0].description);
assertEquals(7, sfs[0].begin);
assertEquals(12, sfs[0].end);
- assertEquals("Intron1", sfs[1].type);
+ assertEquals("Intron1 (Adh)", sfs[1].type);
assertEquals("Domain", sfs[1].description);
assertEquals(13, sfs[1].begin);
assertEquals(18, sfs[1].end);
- assertEquals("Adh", sfs[2].type);
- assertEquals("Gene", sfs[2].description);
- assertEquals(7, sfs[2].begin);
+ assertEquals("Exon2 (Adh)", sfs[2].type);
+ assertEquals("Domain", sfs[2].description);
+ assertEquals(19, sfs[2].begin);
assertEquals(24, sfs[2].end);
- assertEquals("Exon2", sfs[3].type);
- assertEquals("Domain", sfs[3].description);
- assertEquals(19, sfs[3].begin);
+ assertEquals("Adh", sfs[3].type);
+ assertEquals("Gene", sfs[3].description);
+ assertEquals(7, sfs[3].begin);
assertEquals(24, sfs[3].end);
assertEquals("BindingSite", sfs[4].type);
assertEquals("Domain", sfs[4].description);