2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
24 import jalview.api.AlignExportSettingI;
25 import jalview.api.AlignViewportI;
26 import jalview.api.AlignmentViewPanel;
27 import jalview.api.ComplexAlignFile;
28 import jalview.api.FeatureRenderer;
29 import jalview.api.FeatureSettingsModelI;
30 import jalview.api.FeaturesDisplayedI;
31 import jalview.bin.BuildDetails;
32 import jalview.datamodel.AlignmentAnnotation;
33 import jalview.datamodel.AlignmentI;
34 import jalview.datamodel.Annotation;
35 import jalview.datamodel.HiddenColumns;
36 import jalview.datamodel.HiddenSequences;
37 import jalview.datamodel.Sequence;
38 import jalview.datamodel.SequenceFeature;
39 import jalview.datamodel.SequenceGroup;
40 import jalview.datamodel.SequenceI;
41 import jalview.json.binding.biojson.v1.AlignmentAnnotationPojo;
42 import jalview.json.binding.biojson.v1.AlignmentPojo;
43 import jalview.json.binding.biojson.v1.AnnotationDisplaySettingPojo;
44 import jalview.json.binding.biojson.v1.AnnotationPojo;
45 import jalview.json.binding.biojson.v1.ColourSchemeMapper;
46 import jalview.json.binding.biojson.v1.SequenceFeaturesPojo;
47 import jalview.json.binding.biojson.v1.SequenceGrpPojo;
48 import jalview.json.binding.biojson.v1.SequencePojo;
49 import jalview.renderer.seqfeatures.FeatureColourFinder;
50 import jalview.schemes.ColourSchemeProperty;
51 import jalview.schemes.JalviewColourScheme;
52 import jalview.schemes.ResidueColourScheme;
53 import jalview.util.ColorUtils;
54 import jalview.util.Format;
55 import jalview.viewmodel.seqfeatures.FeaturesDisplayed;
57 import java.awt.Color;
58 import java.io.IOException;
59 import java.io.Reader;
60 import java.util.ArrayList;
61 import java.util.Hashtable;
62 import java.util.Iterator;
63 import java.util.List;
64 import java.util.Vector;
66 import org.json.simple.JSONArray;
67 import org.json.simple.JSONObject;
68 import org.json.simple.parser.JSONParser;
70 public class JSONFile extends AlignFile implements ComplexAlignFile
72 private static String version = new BuildDetails().getVersion();
74 private String webstartUrl = "http://www.jalview.org/services/launchApp";
76 private String application = "Jalview";
78 private String globalColourScheme;
80 private boolean showSeqFeatures;
82 private Hashtable<String, Sequence> seqMap;
84 private FeaturesDisplayedI displayedFeatures;
86 private FeatureRenderer fr;
88 private HiddenColumns hiddenColumns;
90 private List<String> hiddenSeqRefs;
92 private ArrayList<SequenceI> hiddenSequences;
94 private final static String TCOFFEE_SCORE = "TCoffeeScore";
101 public JSONFile(FileParse source) throws IOException
106 public JSONFile(String inFile, DataSourceType sourceType)
109 super(inFile, sourceType);
113 public void parse() throws IOException
120 public String print(SequenceI[] sqs, boolean jvsuffix)
122 String jsonOutput = null;
125 AlignmentPojo jsonAlignmentPojo = new AlignmentPojo();
126 AlignExportSettingI exportSettings = getExportSettings();
128 // if no export settings were supplied use the following with all values
129 // defaulting to true
130 if (exportSettings == null)
132 exportSettings = new AlignExportSettingI()
135 public boolean isExportHiddenSequences()
141 public boolean isExportHiddenColumns()
147 public boolean isExportGroups()
153 public boolean isExportFeatures()
159 public boolean isExportAnnotations()
165 public boolean isCancelled()
173 for (SequenceI seq : sqs)
175 StringBuilder name = new StringBuilder();
176 name.append(seq.getName()).append("/").append(seq.getStart())
177 .append("-").append(seq.getEnd());
178 SequencePojo jsonSeqPojo = new SequencePojo();
179 jsonSeqPojo.setId(String.valueOf(seq.hashCode()));
180 jsonSeqPojo.setOrder(++count);
181 jsonSeqPojo.setEnd(seq.getEnd());
182 jsonSeqPojo.setStart(seq.getStart());
183 jsonSeqPojo.setName(name.toString());
184 jsonSeqPojo.setSeq(seq.getSequenceAsString());
185 jsonAlignmentPojo.getSeqs().add(jsonSeqPojo);
187 jsonAlignmentPojo.setGlobalColorScheme(globalColourScheme);
188 jsonAlignmentPojo.getAppSettings().put("application", application);
189 jsonAlignmentPojo.getAppSettings().put("version", version);
190 jsonAlignmentPojo.getAppSettings().put("webStartUrl", webstartUrl);
191 jsonAlignmentPojo.getAppSettings().put("showSeqFeatures",
192 String.valueOf(showSeqFeatures));
194 String[] hiddenSections = getHiddenSections();
195 if (hiddenSections != null)
197 if (hiddenSections[0] != null
198 && exportSettings.isExportHiddenColumns())
200 jsonAlignmentPojo.getAppSettings().put("hiddenCols",
201 String.valueOf(hiddenSections[0]));
203 if (hiddenSections[1] != null
204 && exportSettings.isExportHiddenSequences())
206 jsonAlignmentPojo.getAppSettings().put("hiddenSeqs",
207 String.valueOf(hiddenSections[1]));
211 if (exportSettings.isExportAnnotations())
214 .setAlignAnnotation(annotationToJsonPojo(annotations));
218 // These color schemes require annotation, disable them if annotations
220 if (globalColourScheme
221 .equalsIgnoreCase(JalviewColourScheme.RNAHelices.toString())
222 || globalColourScheme.equalsIgnoreCase(
223 JalviewColourScheme.TCoffee.toString()))
225 jsonAlignmentPojo.setGlobalColorScheme(ResidueColourScheme.NONE);
229 if (exportSettings.isExportFeatures())
231 jsonAlignmentPojo.setSeqFeatures(sequenceFeatureToJsonPojo(sqs));
234 if (exportSettings.isExportGroups() && seqGroups != null
235 && seqGroups.size() > 0)
237 for (SequenceGroup seqGrp : seqGroups)
239 SequenceGrpPojo seqGrpPojo = new SequenceGrpPojo();
240 seqGrpPojo.setGroupName(seqGrp.getName());
241 seqGrpPojo.setColourScheme(ColourSchemeProperty
242 .getColourName(seqGrp.getColourScheme()));
243 seqGrpPojo.setColourText(seqGrp.getColourText());
244 seqGrpPojo.setDescription(seqGrp.getDescription());
245 seqGrpPojo.setDisplayBoxes(seqGrp.getDisplayBoxes());
246 seqGrpPojo.setDisplayText(seqGrp.getDisplayText());
247 seqGrpPojo.setEndRes(seqGrp.getEndRes());
248 seqGrpPojo.setStartRes(seqGrp.getStartRes());
249 seqGrpPojo.setShowNonconserved(seqGrp.getShowNonconserved());
250 for (SequenceI seq : seqGrp.getSequences())
252 seqGrpPojo.getSequenceRefs()
253 .add(String.valueOf(seq.hashCode()));
255 jsonAlignmentPojo.getSeqGroups().add(seqGrpPojo);
258 org.json.JSONObject generatedJSon = new org.json.JSONObject(
260 jsonOutput = generatedJSon.toString();
261 return jsonOutput.replaceAll("xstart", "xStart").replaceAll("xend",
263 } catch (Exception e)
270 public String[] getHiddenSections()
272 String[] hiddenSections = new String[2];
273 if (getViewport() == null)
278 // hidden column business
279 if (getViewport().hasHiddenColumns())
281 hiddenSections[0] = getViewport().getAlignment().getHiddenColumns()
282 .regionsToString(";", "-");
285 // hidden rows/seqs business
286 HiddenSequences hiddenSeqsObj = getViewport().getAlignment()
287 .getHiddenSequences();
288 if (hiddenSeqsObj == null || hiddenSeqsObj.hiddenSequences == null)
290 return hiddenSections;
293 SequenceI[] hiddenSeqs = hiddenSeqsObj.hiddenSequences;
294 StringBuilder hiddenSeqsBuilder = new StringBuilder();
295 for (SequenceI hiddenSeq : hiddenSeqs)
297 if (hiddenSeq != null)
299 hiddenSeqsBuilder.append(";").append(hiddenSeq.hashCode());
302 if (hiddenSeqsBuilder.length() > 0)
304 hiddenSeqsBuilder.deleteCharAt(0);
306 hiddenSections[1] = hiddenSeqsBuilder.toString();
308 return hiddenSections;
311 protected List<SequenceFeaturesPojo> sequenceFeatureToJsonPojo(
314 displayedFeatures = (fr == null) ? null : fr.getFeaturesDisplayed();
315 List<SequenceFeaturesPojo> sequenceFeaturesPojo = new ArrayList<>();
318 return sequenceFeaturesPojo;
321 FeatureColourFinder finder = new FeatureColourFinder(fr);
323 String[] visibleFeatureTypes = displayedFeatures == null ? null
324 : displayedFeatures.getVisibleFeatures().toArray(
325 new String[displayedFeatures.getVisibleFeatureCount()]);
327 for (SequenceI seq : sqs)
330 * get all features currently visible (and any non-positional features)
332 List<SequenceFeature> seqFeatures = seq.getFeatures().getAllFeatures(
333 visibleFeatureTypes);
334 for (SequenceFeature sf : seqFeatures)
336 SequenceFeaturesPojo jsonFeature = new SequenceFeaturesPojo(
337 String.valueOf(seq.hashCode()));
339 String featureColour = (fr == null) ? null : Format
340 .getHexString(finder.findFeatureColour(Color.white, seq,
341 seq.findIndex(sf.getBegin())));
342 int xStart = sf.getBegin() == 0 ? 0
343 : seq.findIndex(sf.getBegin()) - 1;
344 int xEnd = sf.getEnd() == 0 ? 0 : seq.findIndex(sf.getEnd());
345 jsonFeature.setXstart(xStart);
346 jsonFeature.setXend(xEnd);
347 jsonFeature.setType(sf.getType());
348 jsonFeature.setDescription(sf.getDescription());
349 jsonFeature.setLinks(sf.links);
350 jsonFeature.setOtherDetails(sf.otherDetails);
351 jsonFeature.setScore(sf.getScore());
352 jsonFeature.setFillColor(featureColour);
353 jsonFeature.setFeatureGroup(sf.getFeatureGroup());
354 sequenceFeaturesPojo.add(jsonFeature);
357 return sequenceFeaturesPojo;
360 public static List<AlignmentAnnotationPojo> annotationToJsonPojo(
361 Vector<AlignmentAnnotation> annotations)
363 List<AlignmentAnnotationPojo> jsonAnnotations = new ArrayList<>();
364 if (annotations == null)
366 return jsonAnnotations;
368 for (AlignmentAnnotation annot : annotations)
370 AlignmentAnnotationPojo alignAnnotPojo = new AlignmentAnnotationPojo();
371 alignAnnotPojo.setDescription(annot.description);
372 alignAnnotPojo.setLabel(annot.label);
373 if (!Double.isNaN(annot.score))
375 alignAnnotPojo.setScore(annot.score);
377 alignAnnotPojo.setCalcId(annot.getCalcId());
378 alignAnnotPojo.setGraphType(annot.graph);
380 AnnotationDisplaySettingPojo annotSetting = new AnnotationDisplaySettingPojo();
381 annotSetting.setBelowAlignment(annot.belowAlignment);
382 annotSetting.setCentreColLabels(annot.centreColLabels);
383 annotSetting.setScaleColLabel(annot.scaleColLabel);
384 annotSetting.setShowAllColLabels(annot.showAllColLabels);
385 annotSetting.setVisible(annot.visible);
386 annotSetting.setHasIcon(annot.hasIcons);
387 alignAnnotPojo.setAnnotationSettings(annotSetting);
388 SequenceI refSeq = annot.sequenceRef;
391 alignAnnotPojo.setSequenceRef(String.valueOf(refSeq.hashCode()));
393 for (Annotation annotation : annot.annotations)
395 AnnotationPojo annotationPojo = new AnnotationPojo();
396 if (annotation != null)
398 annotationPojo.setDescription(annotation.description);
399 annotationPojo.setValue(annotation.value);
401 .setSecondaryStructure(annotation.secondaryStructure);
402 String displayChar = annotation.displayCharacter == null ? null
403 : annotation.displayCharacter;
404 // System.out.println("--------------------->[" + displayChar + "]");
405 annotationPojo.setDisplayCharacter(displayChar);
406 if (annotation.colour != null)
408 annotationPojo.setColour(
409 jalview.util.Format.getHexString(annotation.colour));
411 alignAnnotPojo.getAnnotations().add(annotationPojo);
415 if (annot.getCalcId() != null
416 && annot.getCalcId().equalsIgnoreCase(TCOFFEE_SCORE))
422 alignAnnotPojo.getAnnotations().add(annotationPojo);
426 jsonAnnotations.add(alignAnnotPojo);
428 return jsonAnnotations;
431 @SuppressWarnings("unchecked")
432 public JSONFile parse(Reader jsonAlignmentString)
436 JSONParser jsonParser = new JSONParser();
437 JSONObject alignmentJsonObj = (JSONObject) jsonParser
438 .parse(jsonAlignmentString);
439 JSONArray seqJsonArray = (JSONArray) alignmentJsonObj.get("seqs");
440 JSONArray alAnnotJsonArray = (JSONArray) alignmentJsonObj
441 .get("alignAnnotation");
442 JSONArray jsonSeqArray = (JSONArray) alignmentJsonObj
444 JSONArray seqGrpJsonArray = (JSONArray) alignmentJsonObj
446 JSONObject jvSettingsJsonObj = (JSONObject) alignmentJsonObj
449 if (jvSettingsJsonObj != null)
451 globalColourScheme = (String) jvSettingsJsonObj
452 .get("globalColorScheme");
453 Boolean showFeatures = Boolean.valueOf(
454 jvSettingsJsonObj.get("showSeqFeatures").toString());
455 setShowSeqFeatures(showFeatures);
456 parseHiddenSeqRefsAsList(jvSettingsJsonObj);
457 parseHiddenCols(jvSettingsJsonObj);
460 hiddenSequences = new ArrayList<>();
461 seqMap = new Hashtable<>();
462 for (Iterator<JSONObject> sequenceIter = seqJsonArray
463 .iterator(); sequenceIter.hasNext();)
465 JSONObject sequence = sequenceIter.next();
466 String sequcenceString = sequence.get("seq").toString();
467 String sequenceName = sequence.get("name").toString();
468 String seqUniqueId = sequence.get("id").toString();
469 int start = Integer.valueOf(sequence.get("start").toString());
470 int end = Integer.valueOf(sequence.get("end").toString());
471 Sequence seq = new Sequence(sequenceName, sequcenceString, start,
473 if (hiddenSeqRefs != null && hiddenSeqRefs.contains(seqUniqueId))
475 hiddenSequences.add(seq);
478 seqMap.put(seqUniqueId, seq);
481 parseFeatures(jsonSeqArray);
483 for (Iterator<JSONObject> seqGrpIter = seqGrpJsonArray
484 .iterator(); seqGrpIter.hasNext();)
486 JSONObject seqGrpObj = seqGrpIter.next();
487 String grpName = seqGrpObj.get("groupName").toString();
488 String colourScheme = seqGrpObj.get("colourScheme").toString();
489 String description = (seqGrpObj.get("description") == null) ? null
490 : seqGrpObj.get("description").toString();
491 boolean displayBoxes = Boolean
492 .valueOf(seqGrpObj.get("displayBoxes").toString());
493 boolean displayText = Boolean
494 .valueOf(seqGrpObj.get("displayText").toString());
495 boolean colourText = Boolean
496 .valueOf(seqGrpObj.get("colourText").toString());
497 boolean showNonconserved = Boolean
498 .valueOf(seqGrpObj.get("showNonconserved").toString());
499 int startRes = Integer
500 .valueOf(seqGrpObj.get("startRes").toString());
501 int endRes = Integer.valueOf(seqGrpObj.get("endRes").toString());
502 JSONArray sequenceRefs = (JSONArray) seqGrpObj.get("sequenceRefs");
504 ArrayList<SequenceI> grpSeqs = new ArrayList<>();
505 if (sequenceRefs.size() > 0)
507 Iterator<String> seqHashIter = sequenceRefs.iterator();
508 while (seqHashIter.hasNext())
510 String seqHash = seqHashIter.next();
511 Sequence sequence = seqMap.get(seqHash);
512 if (sequence != null)
514 grpSeqs.add(sequence);
518 SequenceGroup seqGrp = new SequenceGroup(grpSeqs, grpName, null,
519 displayBoxes, displayText, colourText, startRes, endRes);
520 seqGrp.setColourScheme(ColourSchemeMapper
521 .getJalviewColourScheme(colourScheme, seqGrp));
522 seqGrp.setShowNonconserved(showNonconserved);
523 seqGrp.setDescription(description);
524 this.seqGroups.add(seqGrp);
528 for (Iterator<JSONObject> alAnnotIter = alAnnotJsonArray
529 .iterator(); alAnnotIter.hasNext();)
531 JSONObject alAnnot = alAnnotIter.next();
532 JSONArray annotJsonArray = (JSONArray) alAnnot.get("annotations");
533 Annotation[] annotations = new Annotation[annotJsonArray.size()];
535 for (Iterator<JSONObject> annotIter = annotJsonArray
536 .iterator(); annotIter.hasNext();)
538 JSONObject annot = annotIter.next();
541 annotations[count] = null;
545 float val = annot.get("value") == null ? null
546 : Float.valueOf(annot.get("value").toString());
547 String desc = annot.get("description") == null ? null
548 : annot.get("description").toString();
549 char ss = annot.get("secondaryStructure") == null
550 || annot.get("secondaryStructure").toString()
551 .equalsIgnoreCase("u0000") ? ' '
552 : annot.get("secondaryStructure")
553 .toString().charAt(0);
554 String displayChar = annot.get("displayCharacter") == null ? ""
555 : annot.get("displayCharacter").toString();
557 annotations[count] = new Annotation(displayChar, desc, ss, val);
558 if (annot.get("colour") != null)
560 Color color = ColorUtils
561 .parseColourString(annot.get("colour").toString());
562 annotations[count].colour = color;
568 AlignmentAnnotation alignAnnot = new AlignmentAnnotation(
569 alAnnot.get("label").toString(),
570 alAnnot.get("description").toString(), annotations);
571 alignAnnot.graph = (alAnnot.get("graphType") == null) ? 0
572 : Integer.valueOf(alAnnot.get("graphType").toString());
574 JSONObject diplaySettings = (JSONObject) alAnnot
575 .get("annotationSettings");
576 if (diplaySettings != null)
579 alignAnnot.scaleColLabel = (diplaySettings
580 .get("scaleColLabel") == null) ? false
581 : Boolean.valueOf(diplaySettings
582 .get("scaleColLabel").toString());
583 alignAnnot.showAllColLabels = (diplaySettings
584 .get("showAllColLabels") == null) ? true
585 : Boolean.valueOf(diplaySettings
586 .get("showAllColLabels").toString());
587 alignAnnot.centreColLabels = (diplaySettings
588 .get("centreColLabels") == null) ? true
589 : Boolean.valueOf(diplaySettings
590 .get("centreColLabels").toString());
591 alignAnnot.belowAlignment = (diplaySettings
592 .get("belowAlignment") == null) ? false
593 : Boolean.valueOf(diplaySettings
594 .get("belowAlignment").toString());
595 alignAnnot.visible = (diplaySettings.get("visible") == null)
598 diplaySettings.get("visible").toString());
599 alignAnnot.hasIcons = (diplaySettings.get("hasIcon") == null)
602 diplaySettings.get("hasIcon").toString());
605 if (alAnnot.get("score") != null)
607 alignAnnot.score = Double
608 .valueOf(alAnnot.get("score").toString());
611 String calcId = (alAnnot.get("calcId") == null) ? ""
612 : alAnnot.get("calcId").toString();
613 alignAnnot.setCalcId(calcId);
614 String seqHash = (alAnnot.get("sequenceRef") != null)
615 ? alAnnot.get("sequenceRef").toString()
618 Sequence sequence = (seqHash != null) ? seqMap.get(seqHash) : null;
619 if (sequence != null)
621 alignAnnot.sequenceRef = sequence;
622 sequence.addAlignmentAnnotation(alignAnnot);
623 if (alignAnnot.label.equalsIgnoreCase("T-COFFEE"))
625 alignAnnot.createSequenceMapping(sequence, sequence.getStart(),
627 sequence.addAlignmentAnnotation(alignAnnot);
628 alignAnnot.adjustForAlignment();
631 alignAnnot.validateRangeAndDisplay();
632 this.annotations.add(alignAnnot);
635 } catch (Exception e)
642 public void parseHiddenSeqRefsAsList(JSONObject jvSettingsJson)
644 hiddenSeqRefs = new ArrayList<>();
645 String hiddenSeqs = (String) jvSettingsJson.get("hiddenSeqs");
646 if (hiddenSeqs != null && !hiddenSeqs.isEmpty())
648 String[] seqRefs = hiddenSeqs.split(";");
649 for (String seqRef : seqRefs)
651 hiddenSeqRefs.add(seqRef);
656 public void parseHiddenCols(JSONObject jvSettingsJson)
658 String hiddenCols = (String) jvSettingsJson.get("hiddenCols");
659 if (hiddenCols != null && !hiddenCols.isEmpty())
661 hiddenColumns = new HiddenColumns();
662 String[] rangeStrings = hiddenCols.split(";");
663 for (String rangeString : rangeStrings)
665 String[] range = rangeString.split("-");
666 hiddenColumns.hideColumns(Integer.valueOf(range[0]),
667 Integer.valueOf(range[1]));
672 @SuppressWarnings("unchecked")
673 private void parseFeatures(JSONArray jsonSeqFeatures)
675 if (jsonSeqFeatures != null)
677 displayedFeatures = new FeaturesDisplayed();
678 for (Iterator<JSONObject> seqFeatureItr = jsonSeqFeatures
679 .iterator(); seqFeatureItr.hasNext();)
681 JSONObject jsonFeature = seqFeatureItr.next();
682 Long begin = (Long) jsonFeature.get("xStart");
683 Long end = (Long) jsonFeature.get("xEnd");
684 String type = (String) jsonFeature.get("type");
685 String featureGrp = (String) jsonFeature.get("featureGroup");
686 String description = (String) jsonFeature.get("description");
687 String seqRef = (String) jsonFeature.get("sequenceRef");
688 Float score = Float.valueOf(jsonFeature.get("score").toString());
690 Sequence seq = seqMap.get(seqRef);
693 * begin/end of 0 is for a non-positional feature
695 int featureBegin = begin.intValue() == 0 ? 0 : seq
696 .findPosition(begin.intValue());
697 int featureEnd = end.intValue() == 0 ? 0 : seq.findPosition(end
700 SequenceFeature sequenceFeature = new SequenceFeature(type,
701 description, featureBegin, featureEnd, score, featureGrp);
703 JSONArray linksJsonArray = (JSONArray) jsonFeature.get("links");
704 if (linksJsonArray != null && linksJsonArray.size() > 0)
706 Iterator<String> linkList = linksJsonArray.iterator();
707 while (linkList.hasNext())
709 String link = linkList.next();
710 sequenceFeature.addLink(link);
714 seq.addSequenceFeature(sequenceFeature);
715 displayedFeatures.setVisible(type);
721 public String getGlobalColourScheme()
723 return globalColourScheme;
726 public void setGlobalColorScheme(String globalColourScheme)
728 this.globalColourScheme = globalColourScheme;
732 public FeaturesDisplayedI getDisplayedFeatures()
734 return displayedFeatures;
737 public void setDisplayedFeatures(FeaturesDisplayedI displayedFeatures)
739 this.displayedFeatures = displayedFeatures;
743 public void configureForView(AlignmentViewPanel avpanel)
749 super.configureForView(avpanel);
750 AlignViewportI viewport = avpanel.getAlignViewport();
751 AlignmentI alignment = viewport.getAlignment();
752 AlignmentAnnotation[] annots = alignment.getAlignmentAnnotation();
754 seqGroups = alignment.getGroups();
755 fr = avpanel.cloneFeatureRenderer();
757 // Add non auto calculated annotation to AlignFile
760 for (AlignmentAnnotation annot : annots)
762 if (annot != null && !annot.autoCalculated)
764 annotations.add(annot);
768 globalColourScheme = ColourSchemeProperty
769 .getColourName(viewport.getGlobalColourScheme());
770 setDisplayedFeatures(viewport.getFeaturesDisplayed());
771 showSeqFeatures = viewport.isShowSequenceFeatures();
776 public boolean isShowSeqFeatures()
778 return showSeqFeatures;
781 public void setShowSeqFeatures(boolean showSeqFeatures)
783 this.showSeqFeatures = showSeqFeatures;
786 public Vector<AlignmentAnnotation> getAnnotations()
792 public HiddenColumns getHiddenColumns()
794 return hiddenColumns;
797 public void setHiddenColumns(HiddenColumns hidden)
799 this.hiddenColumns = hidden;
803 public SequenceI[] getHiddenSequences()
805 if (hiddenSequences == null || hiddenSequences.isEmpty())
807 return new SequenceI[] {};
809 synchronized (hiddenSequences)
811 return hiddenSequences.toArray(new SequenceI[hiddenSequences.size()]);
815 public void setHiddenSequences(ArrayList<SequenceI> hiddenSequences)
817 this.hiddenSequences = hiddenSequences;
820 public class JSONExportSettings
822 private boolean exportSequence;
824 private boolean exportSequenceFeatures;
826 private boolean exportAnnotations;
828 private boolean exportGroups;
830 private boolean exportJalviewSettings;
832 public boolean isExportSequence()
834 return exportSequence;
837 public void setExportSequence(boolean exportSequence)
839 this.exportSequence = exportSequence;
842 public boolean isExportSequenceFeatures()
844 return exportSequenceFeatures;
847 public void setExportSequenceFeatures(boolean exportSequenceFeatures)
849 this.exportSequenceFeatures = exportSequenceFeatures;
852 public boolean isExportAnnotations()
854 return exportAnnotations;
857 public void setExportAnnotations(boolean exportAnnotations)
859 this.exportAnnotations = exportAnnotations;
862 public boolean isExportGroups()
867 public void setExportGroups(boolean exportGroups)
869 this.exportGroups = exportGroups;
872 public boolean isExportJalviewSettings()
874 return exportJalviewSettings;
877 public void setExportJalviewSettings(boolean exportJalviewSettings)
879 this.exportJalviewSettings = exportJalviewSettings;
884 * Returns a descriptor for suitable feature display settings with
886 * <li>ResNums or insertions features visible</li>
887 * <li>insertions features coloured red</li>
888 * <li>ResNum features coloured by label</li>
889 * <li>Insertions displayed above (on top of) ResNums</li>
893 public FeatureSettingsModelI getFeatureColourScheme()
895 return new PDBFeatureSettings();