X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fio%2FJSONFile.java;fp=src%2Fjalview%2Fio%2FJSONFile.java;h=2ee305f811678d8819d329f1ffa0f2f2d3e335c4;hb=9c98d4bd666346f6ad3892c5394b7da3be82d93e;hp=022148a4e6fdc27bc93a8e18ce60231c1749101a;hpb=c7b2143c9cf7c5e05ad63251f7d3910751b16d20;p=jalview.git diff --git a/src/jalview/io/JSONFile.java b/src/jalview/io/JSONFile.java index 022148a..2ee305f 100644 --- a/src/jalview/io/JSONFile.java +++ b/src/jalview/io/JSONFile.java @@ -218,7 +218,7 @@ public class JSONFile extends AlignFile implements ComplexAlignFile jsonAlignmentPojo.getSeqGroups().add(seqGrpPojo); } } - + jsonOutput = JSONUtils.stringify(jsonAlignmentPojo); return jsonOutput.replaceAll("xstart", "xStart").replaceAll("xend", "xEnd"); @@ -291,16 +291,16 @@ public class JSONFile extends AlignFile implements ComplexAlignFile /* * get all features currently visible (and any non-positional features) */ - List seqFeatures = seq.getFeatures().getAllFeatures( - visibleFeatureTypes); + List seqFeatures = seq.getFeatures() + .getAllFeatures(visibleFeatureTypes); for (SequenceFeature sf : seqFeatures) { SequenceFeaturesPojo jsonFeature = new SequenceFeaturesPojo( String.valueOf(seq.hashCode())); - String featureColour = (fr == null) ? null : Format - .getHexString(finder.findFeatureColour(Color.white, seq, - seq.findIndex(sf.getBegin()))); + String featureColour = (fr == null) ? null + : Format.getHexString(finder.findFeatureColour(Color.white, + seq, seq.findIndex(sf.getBegin()))); int xStart = sf.getBegin() == 0 ? 0 : seq.findIndex(sf.getBegin()) - 1; int xEnd = sf.getEnd() == 0 ? 0 : seq.findIndex(sf.getEnd()); @@ -395,8 +395,10 @@ public class JSONFile extends AlignFile implements ComplexAlignFile { try { - Map alignmentJsonObj = (Map) JSONUtils.parse(jsonAlignmentString); - List seqJsonArray = (List) alignmentJsonObj.get("seqs"); + Map alignmentJsonObj = (Map) JSONUtils + .parse(jsonAlignmentString); + List seqJsonArray = (List) alignmentJsonObj + .get("seqs"); List alAnnotJsonArray = (List) alignmentJsonObj .get("alignAnnotation"); List jsonSeqArray = (List) alignmentJsonObj @@ -419,9 +421,11 @@ public class JSONFile extends AlignFile implements ComplexAlignFile hiddenSequences = new ArrayList<>(); seqMap = new Hashtable<>(); - for (Iterator sequenceIter = seqJsonArray.iterator(); sequenceIter.hasNext();) + for (Iterator sequenceIter = seqJsonArray + .iterator(); sequenceIter.hasNext();) { - Map sequence = (Map) sequenceIter.next(); + Map sequence = (Map) sequenceIter + .next(); String sequcenceString = sequence.get("seq").toString(); String sequenceName = sequence.get("name").toString(); String seqUniqueId = sequence.get("id").toString(); @@ -439,9 +443,11 @@ public class JSONFile extends AlignFile implements ComplexAlignFile parseFeatures(jsonSeqArray); - for (Iterator seqGrpIter = seqGrpJsonArray.iterator(); seqGrpIter.hasNext();) + for (Iterator seqGrpIter = seqGrpJsonArray + .iterator(); seqGrpIter.hasNext();) { - Map seqGrpObj = (Map)seqGrpIter.next(); + Map seqGrpObj = (Map) seqGrpIter + .next(); String grpName = seqGrpObj.get("groupName").toString(); String colourScheme = seqGrpObj.get("colourScheme").toString(); String description = (seqGrpObj.get("description") == null) ? null @@ -457,7 +463,8 @@ public class JSONFile extends AlignFile implements ComplexAlignFile int startRes = Integer .valueOf(seqGrpObj.get("startRes").toString()); int endRes = Integer.valueOf(seqGrpObj.get("endRes").toString()); - List sequenceRefs = (List) seqGrpObj.get("sequenceRefs"); + List sequenceRefs = (List) seqGrpObj + .get("sequenceRefs"); ArrayList grpSeqs = new ArrayList<>(); if (sequenceRefs.size() > 0) @@ -482,15 +489,20 @@ public class JSONFile extends AlignFile implements ComplexAlignFile } - for (Iterator alAnnotIter = alAnnotJsonArray.iterator(); alAnnotIter.hasNext();) + for (Iterator alAnnotIter = alAnnotJsonArray + .iterator(); alAnnotIter.hasNext();) { - Map alAnnot = (Map) alAnnotIter.next(); - List annotJsonArray = (List) alAnnot.get("annotations"); + Map alAnnot = (Map) alAnnotIter + .next(); + List annotJsonArray = (List) alAnnot + .get("annotations"); Annotation[] annotations = new Annotation[annotJsonArray.size()]; int count = 0; - for (Iterator annotIter = annotJsonArray.iterator(); annotIter.hasNext();) + for (Iterator annotIter = annotJsonArray + .iterator(); annotIter.hasNext();) { - Map annot = (Map) annotIter.next(); + Map annot = (Map) annotIter + .next(); if (annot == null) { annotations[count] = null; @@ -632,7 +644,7 @@ public class JSONFile extends AlignFile implements ComplexAlignFile displayedFeatures = new FeaturesDisplayed(); for (Object o : jsonSeqFeatures) { - Map jsonFeature = (Map) o; + Map jsonFeature = (Map) o; Long begin = (Long) jsonFeature.get("xStart"); Long end = (Long) jsonFeature.get("xEnd"); String type = (String) jsonFeature.get("type"); @@ -646,15 +658,16 @@ public class JSONFile extends AlignFile implements ComplexAlignFile /* * begin/end of 0 is for a non-positional feature */ - int featureBegin = begin.intValue() == 0 ? 0 : seq - .findPosition(begin.intValue()); - int featureEnd = end.intValue() == 0 ? 0 : seq.findPosition(end - .intValue()) - 1; + int featureBegin = begin.intValue() == 0 ? 0 + : seq.findPosition(begin.intValue()); + int featureEnd = end.intValue() == 0 ? 0 + : seq.findPosition(end.intValue()) - 1; SequenceFeature sequenceFeature = new SequenceFeature(type, description, featureBegin, featureEnd, score, featureGrp); - List linksJsonArray = (List) jsonFeature.get("links"); + List linksJsonArray = (List) jsonFeature + .get("links"); if (linksJsonArray != null && linksJsonArray.size() > 0) { Iterator linkList = linksJsonArray.iterator();