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.JalviewColourScheme;
51 import jalview.schemes.ResidueColourScheme;
52 import jalview.util.ColorUtils;
53 import jalview.viewmodel.seqfeatures.FeaturesDisplayed;
55 import java.awt.Color;
56 import java.io.IOException;
57 import java.io.Reader;
58 import java.util.ArrayList;
59 import java.util.Hashtable;
60 import java.util.Iterator;
61 import java.util.List;
62 import java.util.Vector;
64 import org.json.simple.JSONArray;
65 import org.json.simple.JSONObject;
66 import org.json.simple.parser.JSONParser;
68 public class JSONFile extends AlignFile implements ComplexAlignFile
70 private static String version = new BuildDetails().getVersion();
72 private String webstartUrl = "http://www.jalview.org/services/launchApp";
74 private String application = "Jalview";
76 private String globalColourScheme;
78 private boolean showSeqFeatures;
80 private Hashtable<String, Sequence> seqMap;
82 private FeaturesDisplayedI displayedFeatures;
84 private FeatureRenderer fr;
86 private HiddenColumns hiddenColumns;
88 private List<String> hiddenSeqRefs;
90 private ArrayList<SequenceI> hiddenSequences;
92 private final static String TCOFFEE_SCORE = "TCoffeeScore";
99 public JSONFile(FileParse source) throws IOException
104 public JSONFile(String inFile, DataSourceType sourceType)
107 super(inFile, sourceType);
111 public void parse() throws IOException
118 public String print(SequenceI[] sqs, boolean jvsuffix)
120 String jsonOutput = null;
123 AlignmentPojo jsonAlignmentPojo = new AlignmentPojo();
124 AlignExportSettingI exportSettings = getExportSettings();
126 // if no export settings were supplied use the following with all values
127 // defaulting to true
128 if (exportSettings == null)
130 exportSettings = new AlignExportSettingI()
133 public boolean isExportHiddenSequences()
139 public boolean isExportHiddenColumns()
145 public boolean isExportGroups()
151 public boolean isExportFeatures()
157 public boolean isExportAnnotations()
163 public boolean isCancelled()
171 for (SequenceI seq : sqs)
173 StringBuilder name = new StringBuilder();
174 name.append(seq.getName()).append("/").append(seq.getStart())
175 .append("-").append(seq.getEnd());
176 SequencePojo jsonSeqPojo = new SequencePojo();
177 jsonSeqPojo.setId(String.valueOf(seq.hashCode()));
178 jsonSeqPojo.setOrder(++count);
179 jsonSeqPojo.setEnd(seq.getEnd());
180 jsonSeqPojo.setStart(seq.getStart());
181 jsonSeqPojo.setName(name.toString());
182 jsonSeqPojo.setSeq(seq.getSequenceAsString());
183 jsonAlignmentPojo.getSeqs().add(jsonSeqPojo);
185 jsonAlignmentPojo.setGlobalColorScheme(globalColourScheme);
186 jsonAlignmentPojo.getAppSettings().put("application", application);
187 jsonAlignmentPojo.getAppSettings().put("version", version);
188 jsonAlignmentPojo.getAppSettings().put("webStartUrl", webstartUrl);
189 jsonAlignmentPojo.getAppSettings().put("showSeqFeatures",
190 String.valueOf(showSeqFeatures));
192 String[] hiddenSections = getHiddenSections();
193 if (hiddenSections != null)
195 if (hiddenSections[0] != null
196 && exportSettings.isExportHiddenColumns())
198 jsonAlignmentPojo.getAppSettings().put("hiddenCols",
199 String.valueOf(hiddenSections[0]));
201 if (hiddenSections[1] != null
202 && exportSettings.isExportHiddenSequences())
204 jsonAlignmentPojo.getAppSettings().put("hiddenSeqs",
205 String.valueOf(hiddenSections[1]));
209 if (exportSettings.isExportAnnotations())
212 .setAlignAnnotation(annotationToJsonPojo(annotations));
216 // These color schemes require annotation, disable them if annotations
218 if (globalColourScheme
219 .equalsIgnoreCase(JalviewColourScheme.RNAHelices.toString())
220 || globalColourScheme
221 .equalsIgnoreCase(JalviewColourScheme.TCoffee
224 jsonAlignmentPojo.setGlobalColorScheme(ResidueColourScheme.NONE);
228 if (exportSettings.isExportFeatures())
231 .setSeqFeatures(sequenceFeatureToJsonPojo(sqs, fr));
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(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 List<int[]> hiddenCols = getViewport().getAlignment()
284 StringBuilder hiddenColsBuilder = new StringBuilder();
285 for (int[] range : hiddenCols)
287 hiddenColsBuilder.append(";").append(range[0]).append("-")
291 hiddenColsBuilder.deleteCharAt(0);
292 hiddenSections[0] = hiddenColsBuilder.toString();
295 // hidden rows/seqs business
296 HiddenSequences hiddenSeqsObj = getViewport().getAlignment()
297 .getHiddenSequences();
298 if (hiddenSeqsObj == null || hiddenSeqsObj.hiddenSequences == null)
300 return hiddenSections;
303 SequenceI[] hiddenSeqs = hiddenSeqsObj.hiddenSequences;
304 StringBuilder hiddenSeqsBuilder = new StringBuilder();
305 for (SequenceI hiddenSeq : hiddenSeqs)
307 if (hiddenSeq != null)
309 hiddenSeqsBuilder.append(";").append(hiddenSeq.hashCode());
312 if (hiddenSeqsBuilder.length() > 0)
314 hiddenSeqsBuilder.deleteCharAt(0);
316 hiddenSections[1] = hiddenSeqsBuilder.toString();
318 return hiddenSections;
321 public List<SequenceFeaturesPojo> sequenceFeatureToJsonPojo(
322 SequenceI[] sqs, FeatureRenderer fr)
324 displayedFeatures = (fr == null) ? null : fr.getFeaturesDisplayed();
325 List<SequenceFeaturesPojo> sequenceFeaturesPojo = new ArrayList<SequenceFeaturesPojo>();
328 return sequenceFeaturesPojo;
331 FeatureColourFinder finder = new FeatureColourFinder(fr);
333 for (SequenceI seq : sqs)
335 SequenceI dataSetSequence = seq.getDatasetSequence();
336 SequenceFeature[] seqFeatures = (dataSetSequence == null) ? null
337 : seq.getDatasetSequence().getSequenceFeatures();
339 seqFeatures = (seqFeatures == null) ? seq.getSequenceFeatures()
341 if (seqFeatures == null)
346 for (SequenceFeature sf : seqFeatures)
348 if (displayedFeatures != null
349 && displayedFeatures.isVisible(sf.getType()))
351 SequenceFeaturesPojo jsonFeature = new SequenceFeaturesPojo(
352 String.valueOf(seq.hashCode()));
354 String featureColour = (fr == null) ? null : jalview.util.Format
355 .getHexString(finder.findFeatureColour(Color.white, seq,
356 seq.findIndex(sf.getBegin())));
357 jsonFeature.setXstart(seq.findIndex(sf.getBegin()) - 1);
358 jsonFeature.setXend(seq.findIndex(sf.getEnd()));
359 jsonFeature.setType(sf.getType());
360 jsonFeature.setDescription(sf.getDescription());
361 jsonFeature.setLinks(sf.links);
362 jsonFeature.setOtherDetails(sf.otherDetails);
363 jsonFeature.setScore(sf.getScore());
364 jsonFeature.setFillColor(featureColour);
365 jsonFeature.setFeatureGroup(sf.getFeatureGroup());
366 sequenceFeaturesPojo.add(jsonFeature);
370 return sequenceFeaturesPojo;
373 public static List<AlignmentAnnotationPojo> annotationToJsonPojo(
374 Vector<AlignmentAnnotation> annotations)
376 List<AlignmentAnnotationPojo> jsonAnnotations = new ArrayList<AlignmentAnnotationPojo>();
377 if (annotations == null)
379 return jsonAnnotations;
381 for (AlignmentAnnotation annot : annotations)
383 AlignmentAnnotationPojo alignAnnotPojo = new AlignmentAnnotationPojo();
384 alignAnnotPojo.setDescription(annot.description);
385 alignAnnotPojo.setLabel(annot.label);
386 if (!Double.isNaN(annot.score))
388 alignAnnotPojo.setScore(annot.score);
390 alignAnnotPojo.setCalcId(annot.getCalcId());
391 alignAnnotPojo.setGraphType(annot.graph);
393 AnnotationDisplaySettingPojo annotSetting = new AnnotationDisplaySettingPojo();
394 annotSetting.setBelowAlignment(annot.belowAlignment);
395 annotSetting.setCentreColLabels(annot.centreColLabels);
396 annotSetting.setScaleColLabel(annot.scaleColLabel);
397 annotSetting.setShowAllColLabels(annot.showAllColLabels);
398 annotSetting.setVisible(annot.visible);
399 annotSetting.setHasIcon(annot.hasIcons);
400 alignAnnotPojo.setAnnotationSettings(annotSetting);
401 SequenceI refSeq = annot.sequenceRef;
404 alignAnnotPojo.setSequenceRef(String.valueOf(refSeq.hashCode()));
406 for (Annotation annotation : annot.annotations)
408 AnnotationPojo annotationPojo = new AnnotationPojo();
409 if (annotation != null)
411 annotationPojo.setDescription(annotation.description);
412 annotationPojo.setValue(annotation.value);
414 .setSecondaryStructure(annotation.secondaryStructure);
415 String displayChar = annotation.displayCharacter == null ? null
416 : annotation.displayCharacter;
417 // System.out.println("--------------------->[" + displayChar + "]");
418 annotationPojo.setDisplayCharacter(displayChar);
419 if (annotation.colour != null)
421 annotationPojo.setColour(jalview.util.Format
422 .getHexString(annotation.colour));
424 alignAnnotPojo.getAnnotations().add(annotationPojo);
428 if (annot.getCalcId() != null
429 && annot.getCalcId().equalsIgnoreCase(TCOFFEE_SCORE))
435 alignAnnotPojo.getAnnotations().add(annotationPojo);
439 jsonAnnotations.add(alignAnnotPojo);
441 return jsonAnnotations;
444 @SuppressWarnings("unchecked")
445 public JSONFile parse(Reader jsonAlignmentString)
449 JSONParser jsonParser = new JSONParser();
450 JSONObject alignmentJsonObj = (JSONObject) jsonParser
451 .parse(jsonAlignmentString);
452 JSONArray seqJsonArray = (JSONArray) alignmentJsonObj.get("seqs");
453 JSONArray alAnnotJsonArray = (JSONArray) alignmentJsonObj
454 .get("alignAnnotation");
455 JSONArray jsonSeqArray = (JSONArray) alignmentJsonObj
457 JSONArray seqGrpJsonArray = (JSONArray) alignmentJsonObj
459 JSONObject jvSettingsJsonObj = (JSONObject) alignmentJsonObj
462 if (jvSettingsJsonObj != null)
464 globalColourScheme = (String) jvSettingsJsonObj
465 .get("globalColorScheme");
466 Boolean showFeatures = Boolean.valueOf(jvSettingsJsonObj.get(
467 "showSeqFeatures").toString());
468 setShowSeqFeatures(showFeatures);
469 parseHiddenSeqRefsAsList(jvSettingsJsonObj);
470 parseHiddenCols(jvSettingsJsonObj);
473 hiddenSequences = new ArrayList<SequenceI>();
474 seqMap = new Hashtable<String, Sequence>();
475 for (Iterator<JSONObject> sequenceIter = seqJsonArray.iterator(); sequenceIter
478 JSONObject sequence = sequenceIter.next();
479 String sequcenceString = sequence.get("seq").toString();
480 String sequenceName = sequence.get("name").toString();
481 String seqUniqueId = sequence.get("id").toString();
482 int start = Integer.valueOf(sequence.get("start").toString());
483 int end = Integer.valueOf(sequence.get("end").toString());
484 Sequence seq = new Sequence(sequenceName, sequcenceString, start,
486 if (hiddenSeqRefs != null && hiddenSeqRefs.contains(seqUniqueId))
488 hiddenSequences.add(seq);
491 seqMap.put(seqUniqueId, seq);
494 parseFeatures(jsonSeqArray);
496 for (Iterator<JSONObject> seqGrpIter = seqGrpJsonArray.iterator(); seqGrpIter
499 JSONObject seqGrpObj = seqGrpIter.next();
500 String grpName = seqGrpObj.get("groupName").toString();
501 String colourScheme = seqGrpObj.get("colourScheme").toString();
502 String description = (seqGrpObj.get("description") == null) ? null
503 : seqGrpObj.get("description").toString();
504 boolean displayBoxes = Boolean.valueOf(seqGrpObj
505 .get("displayBoxes").toString());
506 boolean displayText = Boolean.valueOf(seqGrpObj.get("displayText")
508 boolean colourText = Boolean.valueOf(seqGrpObj.get("colourText")
510 boolean showNonconserved = Boolean.valueOf(seqGrpObj.get(
511 "showNonconserved").toString());
512 int startRes = Integer
513 .valueOf(seqGrpObj.get("startRes").toString());
514 int endRes = Integer.valueOf(seqGrpObj.get("endRes").toString());
515 JSONArray sequenceRefs = (JSONArray) seqGrpObj.get("sequenceRefs");
517 ArrayList<SequenceI> grpSeqs = new ArrayList<SequenceI>();
518 if (sequenceRefs.size() > 0)
520 Iterator<String> seqHashIter = sequenceRefs.iterator();
521 while (seqHashIter.hasNext())
523 String seqHash = seqHashIter.next();
524 Sequence sequence = seqMap.get(seqHash);
525 if (sequence != null)
527 grpSeqs.add(sequence);
531 SequenceGroup seqGrp = new SequenceGroup(grpSeqs, grpName, null,
532 displayBoxes, displayText, colourText, startRes, endRes);
533 seqGrp.setColourScheme(ColourSchemeMapper.getJalviewColourScheme(
534 colourScheme, seqGrp));
535 seqGrp.setShowNonconserved(showNonconserved);
536 seqGrp.setDescription(description);
537 this.seqGroups.add(seqGrp);
541 for (Iterator<JSONObject> alAnnotIter = alAnnotJsonArray.iterator(); alAnnotIter
544 JSONObject alAnnot = alAnnotIter.next();
545 JSONArray annotJsonArray = (JSONArray) alAnnot.get("annotations");
546 Annotation[] annotations = new Annotation[annotJsonArray.size()];
548 for (Iterator<JSONObject> annotIter = annotJsonArray.iterator(); annotIter
551 JSONObject annot = annotIter.next();
554 annotations[count] = null;
558 float val = annot.get("value") == null ? null : Float
559 .valueOf(annot.get("value").toString());
560 String desc = annot.get("description") == null ? null : annot
561 .get("description").toString();
562 char ss = annot.get("secondaryStructure") == null
563 || annot.get("secondaryStructure").toString()
564 .equalsIgnoreCase("u0000") ? ' ' : annot
565 .get("secondaryStructure").toString().charAt(0);
566 String displayChar = annot.get("displayCharacter") == null ? ""
567 : annot.get("displayCharacter").toString();
569 annotations[count] = new Annotation(displayChar, desc, ss, val);
570 if (annot.get("colour") != null)
572 Color color = ColorUtils.parseColourString(annot.get(
573 "colour").toString());
574 annotations[count].colour = color;
580 AlignmentAnnotation alignAnnot = new AlignmentAnnotation(alAnnot
581 .get("label").toString(), alAnnot.get("description")
582 .toString(), annotations);
583 alignAnnot.graph = (alAnnot.get("graphType") == null) ? 0 : Integer
584 .valueOf(alAnnot.get("graphType").toString());
586 JSONObject diplaySettings = (JSONObject) alAnnot
587 .get("annotationSettings");
588 if (diplaySettings != null)
591 alignAnnot.scaleColLabel = (diplaySettings.get("scaleColLabel") == null) ? false
592 : Boolean.valueOf(diplaySettings.get("scaleColLabel")
594 alignAnnot.showAllColLabels = (diplaySettings
595 .get("showAllColLabels") == null) ? true : Boolean
596 .valueOf(diplaySettings.get("showAllColLabels")
598 alignAnnot.centreColLabels = (diplaySettings
599 .get("centreColLabels") == null) ? true
600 : Boolean.valueOf(diplaySettings.get("centreColLabels")
602 alignAnnot.belowAlignment = (diplaySettings.get("belowAlignment") == null) ? false
603 : Boolean.valueOf(diplaySettings.get("belowAlignment")
605 alignAnnot.visible = (diplaySettings.get("visible") == null) ? true
606 : Boolean.valueOf(diplaySettings.get("visible")
608 alignAnnot.hasIcons = (diplaySettings.get("hasIcon") == null) ? true
609 : Boolean.valueOf(diplaySettings.get("hasIcon")
613 if (alAnnot.get("score") != null)
615 alignAnnot.score = Double
616 .valueOf(alAnnot.get("score").toString());
619 String calcId = (alAnnot.get("calcId") == null) ? "" : alAnnot.get(
620 "calcId").toString();
621 alignAnnot.setCalcId(calcId);
622 String seqHash = (alAnnot.get("sequenceRef") != null) ? alAnnot
623 .get("sequenceRef").toString() : null;
625 Sequence sequence = (seqHash != null) ? seqMap.get(seqHash) : null;
626 if (sequence != null)
628 alignAnnot.sequenceRef = sequence;
629 sequence.addAlignmentAnnotation(alignAnnot);
630 if (alignAnnot.label.equalsIgnoreCase("T-COFFEE"))
632 alignAnnot.createSequenceMapping(sequence, sequence.getStart(),
634 sequence.addAlignmentAnnotation(alignAnnot);
635 alignAnnot.adjustForAlignment();
638 alignAnnot.validateRangeAndDisplay();
639 this.annotations.add(alignAnnot);
642 } catch (Exception e)
649 public void parseHiddenSeqRefsAsList(JSONObject jvSettingsJson)
651 hiddenSeqRefs = new ArrayList<String>();
652 String hiddenSeqs = (String) jvSettingsJson.get("hiddenSeqs");
653 if (hiddenSeqs != null && !hiddenSeqs.isEmpty())
655 String[] seqRefs = hiddenSeqs.split(";");
656 for (String seqRef : seqRefs)
658 hiddenSeqRefs.add(seqRef);
663 public void parseHiddenCols(JSONObject jvSettingsJson)
665 String hiddenCols = (String) jvSettingsJson.get("hiddenCols");
666 if (hiddenCols != null && !hiddenCols.isEmpty())
668 hiddenColumns = new HiddenColumns();
669 String[] rangeStrings = hiddenCols.split(";");
670 for (String rangeString : rangeStrings)
672 String[] range = rangeString.split("-");
673 hiddenColumns.hideColumns(Integer.valueOf(range[0]),
674 Integer.valueOf(range[1]));
679 @SuppressWarnings("unchecked")
680 private void parseFeatures(JSONArray jsonSeqFeatures)
682 if (jsonSeqFeatures != null)
684 displayedFeatures = new FeaturesDisplayed();
685 for (Iterator<JSONObject> seqFeatureItr = jsonSeqFeatures.iterator(); seqFeatureItr
688 JSONObject jsonFeature = seqFeatureItr.next();
689 Long begin = (Long) jsonFeature.get("xStart");
690 Long end = (Long) jsonFeature.get("xEnd");
691 String type = (String) jsonFeature.get("type");
692 String featureGrp = (String) jsonFeature.get("featureGroup");
693 String descripiton = (String) jsonFeature.get("description");
694 String seqRef = (String) jsonFeature.get("sequenceRef");
695 Float score = Float.valueOf(jsonFeature.get("score").toString());
697 Sequence seq = seqMap.get(seqRef);
698 SequenceFeature sequenceFeature = new SequenceFeature();
699 JSONArray linksJsonArray = (JSONArray) jsonFeature.get("links");
700 if (linksJsonArray != null && linksJsonArray.size() > 0)
702 Iterator<String> linkList = linksJsonArray.iterator();
703 while (linkList.hasNext())
705 String link = linkList.next();
706 sequenceFeature.addLink(link);
709 sequenceFeature.setFeatureGroup(featureGrp);
710 sequenceFeature.setScore(score);
711 sequenceFeature.setDescription(descripiton);
712 sequenceFeature.setType(type);
713 sequenceFeature.setBegin(seq.findPosition(begin.intValue()));
714 sequenceFeature.setEnd(seq.findPosition(end.intValue()) - 1);
715 seq.addSequenceFeature(sequenceFeature);
716 displayedFeatures.setVisible(type);
722 public String getGlobalColourScheme()
724 return globalColourScheme;
727 public void setGlobalColorScheme(String globalColourScheme)
729 this.globalColourScheme = globalColourScheme;
733 public FeaturesDisplayedI getDisplayedFeatures()
735 return displayedFeatures;
738 public void setDisplayedFeatures(FeaturesDisplayedI displayedFeatures)
740 this.displayedFeatures = displayedFeatures;
744 public void configureForView(AlignmentViewPanel avpanel)
750 super.configureForView(avpanel);
751 AlignViewportI viewport = avpanel.getAlignViewport();
752 AlignmentI alignment = viewport.getAlignment();
753 AlignmentAnnotation[] annots = alignment.getAlignmentAnnotation();
755 seqGroups = alignment.getGroups();
756 fr = avpanel.cloneFeatureRenderer();
758 // Add non auto calculated annotation to AlignFile
761 for (AlignmentAnnotation annot : annots)
763 if (annot != null && !annot.autoCalculated)
765 annotations.add(annot);
769 globalColourScheme = (viewport.getGlobalColourScheme() == null) ? ResidueColourScheme.NONE
770 : viewport.getGlobalColourScheme().getSchemeName();
771 setDisplayedFeatures(viewport.getFeaturesDisplayed());
772 showSeqFeatures = viewport.isShowSequenceFeatures();
777 public boolean isShowSeqFeatures()
779 return showSeqFeatures;
782 public void setShowSeqFeatures(boolean showSeqFeatures)
784 this.showSeqFeatures = showSeqFeatures;
787 public Vector<AlignmentAnnotation> getAnnotations()
793 public HiddenColumns getHiddenColumns()
795 return hiddenColumns;
798 public void setHiddenColumns(HiddenColumns hidden)
800 this.hiddenColumns = hidden;
804 public SequenceI[] getHiddenSequences()
806 if (hiddenSequences == null || hiddenSequences.isEmpty())
808 return new SequenceI[] {};
810 synchronized (hiddenSequences)
812 return hiddenSequences.toArray(new SequenceI[hiddenSequences.size()]);
816 public void setHiddenSequences(ArrayList<SequenceI> hiddenSequences)
818 this.hiddenSequences = hiddenSequences;
821 public class JSONExportSettings
823 private boolean exportSequence;
825 private boolean exportSequenceFeatures;
827 private boolean exportAnnotations;
829 private boolean exportGroups;
831 private boolean exportJalviewSettings;
833 public boolean isExportSequence()
835 return exportSequence;
838 public void setExportSequence(boolean exportSequence)
840 this.exportSequence = exportSequence;
843 public boolean isExportSequenceFeatures()
845 return exportSequenceFeatures;
848 public void setExportSequenceFeatures(boolean exportSequenceFeatures)
850 this.exportSequenceFeatures = exportSequenceFeatures;
853 public boolean isExportAnnotations()
855 return exportAnnotations;
858 public void setExportAnnotations(boolean exportAnnotations)
860 this.exportAnnotations = exportAnnotations;
863 public boolean isExportGroups()
868 public void setExportGroups(boolean exportGroups)
870 this.exportGroups = exportGroups;
873 public boolean isExportJalviewSettings()
875 return exportJalviewSettings;
878 public void setExportJalviewSettings(boolean exportJalviewSettings)
880 this.exportJalviewSettings = exportJalviewSettings;
885 * Returns a descriptor for suitable feature display settings with
887 * <li>ResNums or insertions features visible</li>
888 * <li>insertions features coloured red</li>
889 * <li>ResNum features coloured by label</li>
890 * <li>Insertions displayed above (on top of) ResNums</li>
894 public FeatureSettingsModelI getFeatureColourScheme()
896 return new PDBFeatureSettings();