From aad42885fc9a022c96d4225bb6d18da3553264ed Mon Sep 17 00:00:00 2001 From: tjc <tjc@ee4ac58c-ac51-4696-9907-e4b3aa274f04> Date: Fri, 19 Mar 2010 15:37:23 +0000 Subject: [PATCH] handle UTRs git-svn-id: svn+ssh://svn.internal.sanger.ac.uk/repos/svn/pathsoft/artemis/trunk@13533 ee4ac58c-ac51-4696-9907-e4b3aa274f04 --- .../artemis/io/PublicDBDocumentEntry.java | 57 +++++++++++++++++-- 1 file changed, 52 insertions(+), 5 deletions(-) diff --git a/uk/ac/sanger/artemis/io/PublicDBDocumentEntry.java b/uk/ac/sanger/artemis/io/PublicDBDocumentEntry.java index cf188d9a7..7388e5b95 100644 --- a/uk/ac/sanger/artemis/io/PublicDBDocumentEntry.java +++ b/uk/ac/sanger/artemis/io/PublicDBDocumentEntry.java @@ -207,7 +207,9 @@ public class PublicDBDocumentEntry extends SimpleDocumentEntry } } - + Location location = joinUtrs(feature, key, qualifiers); + if(location == null) + return null; // flatten gene model - combining qualifiers if(key.getKeyString().equals(DatabaseDocument.EXONMODEL)) { @@ -286,13 +288,11 @@ public class PublicDBDocumentEntry extends SimpleDocumentEntry if(this instanceof EmblDocumentEntry) return new EmblStreamFeature ( - key, - feature.getLocation(), + key, location, qualifiers); else return new GenbankStreamFeature ( - key, - feature.getLocation(), + key, location, qualifiers); } catch(InvalidRelationException e) @@ -305,6 +305,53 @@ public class PublicDBDocumentEntry extends SimpleDocumentEntry } } + /** + * Handle UTR joins + * @param feature + * @param key + * @param qualifiers + * @return + */ + private Location joinUtrs(Feature feature, Key key, QualifierVector qualifiers) + { + Location location = feature.getLocation(); + if(key.getKeyString().equals("5'UTR") || + key.getKeyString().equals("3'UTR")) + { + ChadoCanonicalGene gene = ((GFFStreamFeature)feature).getChadoGene(); + String utrName = GeneUtils.getUniqueName(feature); + String transcriptName = gene.getTranscriptFromName(utrName); + List<Feature> utrs; + + if(key.getKeyString().equals("5'UTR")) + utrs = gene.get5UtrOfTranscript(transcriptName); + else + utrs = gene.get3UtrOfTranscript(transcriptName); + + if(utrs.size() > 1) + { + int start = Integer.MAX_VALUE; + RangeVector ranges = new RangeVector(); + for(int i=0; i<utrs.size(); i++) + { + Feature utr = utrs.get(i); + Range range = utr.getLocation().getTotalRange(); + if(start > range.getStart()) + start = range.getStart(); + ranges.add(range); + } + + if(start != feature.getLocation().getTotalRange().getStart()) + return null; + + location = + new Location(ranges, feature.getLocation().isComplement()); + } + qualifiers.setQualifier(new Qualifier("locus_tag", transcriptName)); + qualifiers.removeQualifierByName("ID"); + } + return location; + } /** * Merge qualifiers -- GitLab