* <li>FOLLOW_SELECTIONS (true) Controls whether a new alignment view should
* respond to selections made in other alignments containing the same sequences.
* </li>
+ * <li>SHOW_JWS2_SERVICES (true) when set to false, jalview will not
+ * auto-discover JABAWS services</li>
* <li>JWS2HOSTURLS comma-separated list of URLs to try for JABAWS services</li>
* <li>SHOW_WSDISCOVERY_ERRORS (true) Controls if the web service URL discovery
* warning dialog box is displayed.</li>
* <li>CHIMERA_PATH specify full path to Chimera program (if non-standard)</li>
* <li>ID_ORG_HOSTURL location of jalview service providing identifiers.org urls
* </li>
- *
+ * <li>NONEWS - when set disables Jalview News from automatically appearing</li>
+ * <li>NOHTMLTEMPLATES - when set, the
+ * https://github.com/jalview/exporter-templates/tree/master/biojs repository is
+ * not downloaded automatically</li>
+ * <li>NOIDENTIFIERSSERVICE - when set, jalview won't automatically download
+ * available URL linkouts via www.jalview.org/services/identifiers</li>
+ * <li>
* </ul>
* Deprecated settings:
* <ul>
System.err.println("CMD [-noquestionnaire] executed successfully!");
}
- if (!aparser.contains("nonews"))
+ if (!aparser.contains("nonews")
+ || Cache.getProperty("NONEWS") == null)
{
desktop.checkForNews();
}
- BioJsHTMLOutput.updateBioJS();
+ if (!aparser.contains("nohtmltemplates")
+ || Cache.getProperty("NOHTMLTEMPLATES") == null)
+ {
+ BioJsHTMLOutput.updateBioJS();
+ }
}
// Move any new getdown-launcher-new.jar into place over old
webService.add(me.webServiceNoServices);
}
// TODO: move into separate menu builder class.
- boolean new_sspred = false;
- if (Cache.getDefault("SHOW_JWS2_SERVICES", true))
{
+ // logic for 2.11.1.4 is
+ // always look to see if there is a discover. if there isn't
+ // we can't show any Jws2 services
+ // if there are services available, show them - regardless of
+ // the 'show JWS2 preference'
+ // if the discoverer is running then say so
+ // otherwise offer to trigger discovery if 'show JWS2' is not
+ // enabled
Jws2Discoverer jws2servs = Jws2Discoverer.getDiscoverer();
if (jws2servs != null)
{
}
}
}
-
}
+
if (jws2servs.isRunning())
{
JMenuItem tm = new JMenuItem(
tm.setEnabled(false);
webService.add(tm);
}
+ else if (!Cache.getDefault("SHOW_JWS2_SERVICES", true))
+ {
+ JMenuItem enableJws2 = new JMenuItem(
+ "Discover Web Services");
+ enableJws2.setToolTipText(
+ "Select to start JABA Web Service discovery (or enable option in Web Service preferences)");
+ enableJws2.setEnabled(true);
+ enableJws2.addActionListener(new ActionListener()
+ {
+
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ // start service discoverer, but ignore preference
+ Desktop.instance.startServiceDiscovery(false,
+ true);
+ }
+ });
+ webService.add(enableJws2);
+ }
}
}
build_urlServiceMenu(me.webService);
initItems(chan);
updating = false;
- boolean setvisible = checkForNew(chan, true);
-
- if (setvisible)
+ if (!Cache.getDefault("NONEWS", false))
{
+ boolean setvisible = checkForNew(chan, true);
+
+ if (setvisible)
+ {
- Cache.log.debug("Will show jalview news automatically");
- showNews();
+ Cache.log.debug("Will show jalview news automatically");
+ showNews();
+ }
}
Cache.log.debug("Completed construction of reader.");
public void getIdentifiersOrgData()
{
- // Thread off the identifiers fetcher
- new Thread(new Runnable()
- {
- @Override
- public void run()
+ if (Cache.getProperty("NOIDENTIFIERSSERVICE") == null)
+ {// Thread off the identifiers fetcher
+ new Thread(new Runnable()
{
- Cache.log.debug("Downloading data from identifiers.org");
- UrlDownloadClient client = new UrlDownloadClient();
- try
- {
- client.download(IdOrgSettings.getUrl(),
- IdOrgSettings.getDownloadLocation());
- } catch (IOException e)
+ @Override
+ public void run()
{
- Cache.log.debug("Exception downloading identifiers.org data"
- + e.getMessage());
+ Cache.log.debug("Downloading data from identifiers.org");
+ try
+ {
+ UrlDownloadClient.download(IdOrgSettings.getUrl(),
+ IdOrgSettings.getDownloadLocation());
+ } catch (IOException e)
+ {
+ Cache.log.debug("Exception downloading identifiers.org data"
+ + e.getMessage());
+ }
}
- }
- }).start();
- ;
+ }).start();
+ ;
+ }
}
@Override
this.inBatchMode = inBatchMode;
}
+ /**
+ * start service discovery and wait till it is done
+ */
public void startServiceDiscovery()
{
startServiceDiscovery(false);
}
+ /**
+ * start service discovery threads - blocking or non-blocking
+ *
+ * @param blocking
+ */
public void startServiceDiscovery(boolean blocking)
{
+ startServiceDiscovery(blocking,false);
+ }
+
+ /**
+ * start service discovery threads
+ *
+ * @param blocking
+ * - false means call returns immediately
+ * @param ignore_SHOW_JWS2_SERVICES_preference
+ * - when true JABA services are discovered regardless of user's JWS2
+ * discovery preference setting
+ */
+ public void startServiceDiscovery(boolean blocking,
+ boolean ignore_SHOW_JWS2_SERVICES_preference)
+ {
boolean alive = true;
Thread t0 = null, t1 = null, t2 = null;
// JAL-940 - JALVIEW 1 services are now being EOLed as of JABA 2.1 release
(t0 = new Thread(discoverer)).start();
}
- if (Cache.getDefault("SHOW_JWS2_SERVICES", true))
+ if (ignore_SHOW_JWS2_SERVICES_preference
+ || Cache.getDefault("SHOW_JWS2_SERVICES", true))
{
t2 = jalview.ws.jws2.Jws2Discoverer.getDiscoverer()
.startDiscoverer(changeSupport);
public class UrlDownloadClient
{
- public UrlDownloadClient()
- {
-
- }
-
/**
* Download and save a file from a URL
*
--- /dev/null
+application/x-jalview+xml+zip; jalview -open '%s'; description="Jalview File"; nametemplate=%s.jvp; test=test -n "$DISPLAY"; priority=10
+chemical/x-cif; jalview -open '%s'; description="CIF File"; nametemplate=%s.cif; test=test -n "$DISPLAY"; priority=4
+chemical/x-mmcif; jalview -open '%s'; description="mmCIF File"; nametemplate=%s.mcif; test=test -n "$DISPLAY"; priority=4
+chemical/x-pdb; jalview -open '%s'; description="PDB File"; nametemplate=%s.pdb; test=test -n "$DISPLAY"; priority=4
+application/x-amsa+txt; jalview -open '%s'; description="AMSA File"; nametemplate=%s.amsa; test=test -n "$DISPLAY"; priority=9
+application/x-jalview-annotations+text; jalview -open '%s'; description="Jalview Annotations File"; nametemplate=%s.annotations; test=test -n "$DISPLAY"; priority=10
+application/x-jalview-biojson+json; jalview -open '%s'; description="BioJSON File"; nametemplate=%s.biojson; test=test -n "$DISPLAY"; priority=10
+application/x-blc+txt; jalview -open '%s'; description="BLC File"; nametemplate=%s.blc; test=test -n "$DISPLAY"; priority=9
+application/x-clustal+txt; jalview -open '%s'; description="Clustal File"; nametemplate=%s.aln; test=test -n "$DISPLAY"; priority=9
+application/x-fasta+txt; jalview -open '%s'; description="Fasta File"; nametemplate=%s.fa; test=test -n "$DISPLAY"; priority=9
+application/x-jalview-features+text; jalview -open '%s'; description="Jalview Features File"; nametemplate=%s.features; test=test -n "$DISPLAY"; priority=10
+application/x-gff2+txt; jalview -open '%s'; description="Generic Features Format v2 File"; nametemplate=%s.gff2; test=test -n "$DISPLAY"; priority=9
+application/x-gff3+txt; jalview -open '%s'; description="Generic Features Format v3 File"; nametemplate=%s.gff3; test=test -n "$DISPLAY"; priority=9
+application/x-jalview-jnet+text; jalview -open '%s'; description="JnetFile File"; nametemplate=%s.concise; test=test -n "$DISPLAY"; priority=10
+application/x-msf+txt; jalview -open '%s'; description="MSF File"; nametemplate=%s.msf; test=test -n "$DISPLAY"; priority=9
+application/x-pfam+txt; jalview -open '%s'; description="PFAM File"; nametemplate=%s.pfam; test=test -n "$DISPLAY"; priority=9
+application/x-phylip+txt; jalview -open '%s'; description="PHYLIP File"; nametemplate=%s.phy; test=test -n "$DISPLAY"; priority=9
+application/x-pileup+txt; jalview -open '%s'; description="PileUp File"; nametemplate=%s.pileup; test=test -n "$DISPLAY"; priority=9
+application/x-pir+txt; jalview -open '%s'; description="PIR File"; nametemplate=%s.pir; test=test -n "$DISPLAY"; priority=9
+application/rnaml+xml; jalview -open '%s'; description="RNAML File"; nametemplate=%s.rnaml; test=test -n "$DISPLAY"; priority=9
+application/x-jalview-scorematrix+text; jalview -open '%s'; description="Substitution Matrix File"; nametemplate=%s.mat; test=test -n "$DISPLAY"; priority=10
+application/x-stockholm+txt; jalview -open '%s'; description="Stockholm File"; nametemplate=%s.sto; test=test -n "$DISPLAY"; priority=9
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
+
+ <mime-type type="application/x-jalview+xml+zip">
+ <comment>Jalview File</comment>
+ <icon name="jalview-file"/>
+ <glob pattern="*.jvp" weight="100"/>
+ </mime-type>
+
+ <mime-type type="chemical/x-cif">
+ <comment>CIF File</comment>
+ <icon name="jalview-file"/>
+ <glob pattern="*.cif" weight="40"/>
+ </mime-type>
+
+ <mime-type type="chemical/x-mmcif">
+ <comment>mmCIF File</comment>
+ <icon name="jalview-file"/>
+ <glob pattern="*.mcif" weight="40"/>
+ <glob pattern="*.mmcif" weight="40"/>
+ </mime-type>
+
+ <mime-type type="chemical/x-pdb">
+ <comment>PDB File</comment>
+ <icon name="jalview-file"/>
+ <glob pattern="*.pdb" weight="40"/>
+ <glob pattern="*.ent" weight="40"/>
+ </mime-type>
+
+ <mime-type type="application/x-amsa+txt">
+ <comment>AMSA File</comment>
+ <icon name="jalview-file"/>
+ <glob pattern="*.amsa" weight="90"/>
+ </mime-type>
+
+ <mime-type type="application/x-jalview-annotations+text">
+ <comment>Jalview Annotations File</comment>
+ <icon name="jalview-file"/>
+ <glob pattern="*.annotations" weight="100"/>
+ <glob pattern="*.jvannotations" weight="100"/>
+ </mime-type>
+
+ <mime-type type="application/x-jalview-biojson+json">
+ <comment>BioJSON File</comment>
+ <icon name="jalview-file"/>
+ <glob pattern="*.biojson" weight="100"/>
+ </mime-type>
+
+ <mime-type type="application/x-blc+txt">
+ <comment>BLC File</comment>
+ <icon name="jalview-file"/>
+ <glob pattern="*.blc" weight="90"/>
+ </mime-type>
+
+ <mime-type type="application/x-clustal+txt">
+ <comment>Clustal File</comment>
+ <icon name="jalview-file"/>
+ <glob pattern="*.aln" weight="90"/>
+ </mime-type>
+
+ <mime-type type="application/x-fasta+txt">
+ <comment>Fasta File</comment>
+ <icon name="jalview-file"/>
+ <glob pattern="*.fa" weight="90"/>
+ <glob pattern="*.fasta" weight="90"/>
+ </mime-type>
+
+ <mime-type type="application/x-jalview-features+text">
+ <comment>Jalview Features File</comment>
+ <icon name="jalview-file"/>
+ <glob pattern="*.features" weight="100"/>
+ <glob pattern="*.jvfeatures" weight="100"/>
+ </mime-type>
+
+ <mime-type type="application/x-gff2+txt">
+ <comment>Generic Features Format v2 File</comment>
+ <icon name="jalview-file"/>
+ <glob pattern="*.gff2" weight="90"/>
+ </mime-type>
+
+ <mime-type type="application/x-gff3+txt">
+ <comment>Generic Features Format v3 File</comment>
+ <icon name="jalview-file"/>
+ <glob pattern="*.gff3" weight="90"/>
+ </mime-type>
+
+ <mime-type type="application/x-jalview-jnet+text">
+ <comment>JnetFile File</comment>
+ <icon name="jalview-file"/>
+ <glob pattern="*.concise" weight="100"/>
+ <glob pattern="*.jnet" weight="100"/>
+ </mime-type>
+
+ <mime-type type="application/x-msf+txt">
+ <comment>MSF File</comment>
+ <icon name="jalview-file"/>
+ <glob pattern="*.msf" weight="90"/>
+ </mime-type>
+
+ <mime-type type="application/x-pfam+txt">
+ <comment>PFAM File</comment>
+ <icon name="jalview-file"/>
+ <glob pattern="*.pfam" weight="90"/>
+ </mime-type>
+
+ <mime-type type="application/x-phylip+txt">
+ <comment>PHYLIP File</comment>
+ <icon name="jalview-file"/>
+ <glob pattern="*.phy" weight="90"/>
+ </mime-type>
+
+ <mime-type type="application/x-pileup+txt">
+ <comment>PileUp File</comment>
+ <icon name="jalview-file"/>
+ <glob pattern="*.pileup" weight="90"/>
+ </mime-type>
+
+ <mime-type type="application/x-pir+txt">
+ <comment>PIR File</comment>
+ <icon name="jalview-file"/>
+ <glob pattern="*.pir" weight="90"/>
+ </mime-type>
+
+ <mime-type type="application/rnaml+xml">
+ <comment>RNAML File</comment>
+ <icon name="jalview-file"/>
+ <glob pattern="*.rnaml" weight="90"/>
+ </mime-type>
+
+ <mime-type type="application/x-jalview-scorematrix+text">
+ <comment>Substitution Matrix File</comment>
+ <icon name="jalview-file"/>
+ <glob pattern="*.mat" weight="100"/>
+ </mime-type>
+
+ <mime-type type="application/x-stockholm+txt">
+ <comment>Stockholm File</comment>
+ <icon name="jalview-file"/>
+ <glob pattern="*.sto" weight="90"/>
+ <glob pattern="*.stk" weight="90"/>
+ </mime-type>
+
+</mime-info>
--- /dev/null
+[Desktop Entry]
+Version=1.1
+Type=Application
+Name=Jalview
+Comment=Multiple Sequence Alignment Editor
+Icon=jalview-icon
+Type=Application
+TryExec=jalview
+Exec=jalview -open %u
+Terminal=false
+Categories=Science;Biology;
+Keywords=alignment;sequence;
+MimeType=application/x-jalview+xml+zip;chemical/x-cif;chemical/x-mmcif;chemical/x-pdb;application/x-amsa+txt;application/x-jalview-annotations+text;application/x-jalview-biojson+json;application/x-blc+txt;application/x-clustal+txt;application/x-fasta+txt;application/x-jalview-features+text;application/x-gff2+txt;application/x-gff3+txt;application/x-jalview-jnet+text;application/x-msf+txt;application/x-pfam+txt;application/x-phylip+txt;application/x-pileup+txt;application/x-pir+txt;application/rnaml+xml;application/x-jalview-scorematrix+text;application/x-stockholm+txt
--- /dev/null
+$$MIMETYPE$$; jalview -open '%s'; description="$$NAME$$ File"; nametemplate=%s.$$EXTENSION$$; test=test -n "$DISPLAY"; priority=$$PRIORITY$$
--- /dev/null
+ <mime-type type="$$MIMETYPE$$">
+ <comment>$$NAME$$ File</comment>
+ <icon name="$$ICONFILE$$"/>
+$$ <glob pattern="*.EXTENSIONS" weight="$$PRIORITY$$0"/>
+$$ </mime-type>
+
--- /dev/null
+#!/usr/bin/env perl
+
+use strict;
+
+my $fileformats = $ARGV[0];
+$fileformats = "../../src/jalview/io/FileFormat.java" unless $fileformats;
+
+# default mimetype will be text/x-$shortname
+# TODO: find an actual extension for mat, see JAL-Xxxxx for outstanding issues too
+# TODO: look up standard mime type used for BLASTfmt matrices, etc
+my $mimetypes = {
+ rnaml => "application/rnaml+xml",
+ biojson => "application/x-jalview-biojson+json",
+ jnet => "application/x-jalview-jnet+text",
+ features => "application/x-jalview-features+text",
+ scorematrix => "application/x-jalview-scorematrix+text",
+ pdb => "chemical/x-pdb",
+ mmcif => "chemical/x-cif",
+ mmcif2 => "chemical/x-mmcif",
+ jalview => "application/x-jalview+xml+zip",
+ #jvl => "application/x-jalview-jvl+text",
+ annotations => "application/x-jalview-annotations+text",
+};
+
+my @dontaddshortname = qw(features json);
+my @dontaddextension = qw(html xml json jar mfa fastq);
+my $add_associations = {
+ biojson => {shortname=>"biojson",name=>"BioJSON",extensions=>["biojson"]},
+ gff2 => {shortname=>"gff2",name=>"Generic Features Format v2",extensions=>["gff2"]},
+ gff3 => {shortname=>"gff3",name=>"Generic Features Format v3",extensions=>["gff3"]},
+ features => {shortname=>"features",name=>"Jalview Features",extensions=>["features","jvfeatures"]},
+ annotations => {shortname=>"annotations",name=>"Jalview Annotations",extensions=>["annotations","jvannotations"]},
+ mmcif => {shortname=>"mmcif",name=>"CIF",extensions=>["cif"]},
+ mmcif2 => {shortname=>"mmcif2",name=>"mmCIF",extensions=>["mcif","mmcif"]},
+ #jvl => {shortname=>"jvl",name=>"Jalview Launch",extensions=>["jvl"],iconfile=>"jalview-launch"},
+ jnet => {shortname=>"jnet",name=>"JnetFile",extensions=>["concise","jnet"]},
+ scorematrix => {shortname=>"scorematrix",name=>"Substitution Matrix",extensions=>["mat"]},
+};
+my $add_extensions = {
+ blc => ["blc"],
+};
+my @put_first = qw(jalview jvl);
+
+my @non_primary = qw(mmcif mmcif2 pdb);
+
+my $mailcaptemplatefile = "file_associations_template-mailcap.txt";
+my $mailcaptemplate;
+my $sharedmimeinfotemplatefile = "file_associations_template-shared-mime-info.xml";
+my $sharedmimeinfotemplate;
+
+open(SMT,"<$sharedmimeinfotemplatefile") or die("Could not open '$sharedmimeinfotemplatefile' for reading");
+while(<SMT>){
+ $sharedmimeinfotemplate .= $_;
+}
+close(SMT);
+open(MCT,"<$mailcaptemplatefile") or die("Could not open '$mailcaptemplatefile' for reading");
+while(<MCT>){
+ $mailcaptemplate .= $_;
+}
+close(MCT);
+my $sharedmimeinfoauto;
+my $mailcapauto;
+
+# this file should go in /usr/share/mime/packages
+my $sharedmimeinfoautofile = "debian/jalview-mime.xml";
+
+# this file should go in /usr/lib/mime/packages
+my $mailcapautofile = "debian/jalview-mailcap";
+
+# this should be part of the jalview.desktop file that goes in /usr/shares/applications
+my $desktopfile = "debian/jalview.desktop";
+
+my $MimeType = "";
+
+for my $key (sort keys %$add_associations) {
+ my $a = $add_associations->{$key};
+ warn("Known file association for $a->{shortname} (".join(",",@{$a->{extensions}}).")\n");
+}
+
+open(SMI,">$sharedmimeinfoautofile") or die ("Could not open '$sharedmimeinfoautofile' for writing");
+
+open(MCA,">$mailcapautofile") or die ("Could not open '$mailcapautofile' for writing");
+
+open(IN, "<$fileformats") or die ("Could not open '$fileformats' for reading");
+my $id = 10000;
+my $file_associations = {};
+while(my $line = <IN>) {
+ $line =~ s/\s+/ /g;
+ $line =~ s/(^ | $)//g;
+ if ($line =~ m/^(\w+) ?\( ?"([^"]*)" ?, ?"([^"]*)" ?, ?(true|false) ?, ?(true|false) ?\)$/i) {
+ my $shortname = lc($1);
+ next if (grep($_ eq $shortname, @dontaddshortname));
+ my $name = $2;
+ my $extensions = $3;
+ $extensions =~ s/\s+//g;
+ my @possextensions = map(lc($_),split(m/,/,$extensions));
+ my @extensions;
+ my $addext = $add_extensions->{$shortname};
+ if (ref($addext) eq "ARRAY") {
+ push(@possextensions, @$addext);
+ }
+ for my $possext (@possextensions) {
+ next if grep($_ eq $possext, @extensions);
+ next if grep($_ eq $possext, @dontaddextension);
+ push(@extensions,$possext);
+ }
+ next unless scalar(@extensions);
+ $file_associations->{$shortname} = {
+ shortname => $shortname,
+ name => $name,
+ extensions => \@extensions
+ };
+ warn("Reading file association for $shortname (".join(",",@extensions).")\n");
+ }
+}
+close(IN);
+
+my %all_associations = (%$file_associations, %$add_associations);
+
+my @ordered = (@put_first, @non_primary);
+for my $key (sort keys %all_associations) {
+ next if grep($_ eq $key, @ordered);
+ push(@ordered, $key);
+}
+my $num = $#ordered + 1;
+
+warn("--\n");
+print SMI qq(<?xml version="1.0" encoding="UTF-8"?>\n<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">\n\n);
+
+my $mailcapcount = 0;
+for my $shortname (@ordered) {
+ my $a = $all_associations{$shortname};
+ next if (ref($a) ne "HASH");
+
+ my $name = $a->{name};
+ my $extensions = $a->{extensions};
+ my $mimetype = $mimetypes->{$shortname};
+ $mimetype = "application/x-$shortname+txt" unless $mimetype;
+
+ $MimeType .= $MimeType?";":"";
+ $MimeType .= $mimetype;
+
+ my $iconfile = $a->{iconfile};
+ $iconfile = "jalview-file" unless $iconfile;
+
+ my $primary = (! grep($_ eq $shortname, @non_primary));
+ my $primarystring = $primary?"true":"false";
+ my $role = $primary?"Editor":"Viewer";
+ my $priority = $primary?9:4;
+ $priority = 10 if $mimetype =~ m/\bjalview\b/;
+
+ my @extensions = @$extensions;
+ my $extension0 = $extensions[0];
+
+ my $xname = xml_escape($name);
+ my $xmimetype = xml_escape($mimetype);
+ my $xshortname = xml_escape($shortname);
+ my $xiconfile = xml_escape($iconfile);
+ my $xrole = xml_escape($role);
+ my $xROLE = xml_escape(uc($role));
+ my $xprimarystring = xml_escape($primarystring);
+
+ my $sharedmimeinfoentry = $sharedmimeinfotemplate;
+ $sharedmimeinfoentry =~ s/\$\$NAME\$\$/$xname/g;
+ $sharedmimeinfoentry =~ s/\$\$SHORTNAME\$\$/$xshortname/g;
+ $sharedmimeinfoentry =~ s/\$\$MIMETYPE\$\$/$xmimetype/g;
+ $sharedmimeinfoentry =~ s/\$\$ICONFILE\$\$/$xiconfile/g;
+ $sharedmimeinfoentry =~ s/\$\$ROLE\$\$/$xrole/g;
+ $sharedmimeinfoentry =~ s/\$\$PRIMARY\$\$/$xprimarystring/g;
+ $sharedmimeinfoentry =~ s/\$\$PRIORITY\$\$/$priority/g;
+ while ($sharedmimeinfoentry =~ m/\$\$([^\$]*)EXTENSIONS([^\$]*)\$\$/) {
+ my $pre = $1;
+ my $post = $2;
+ my $sharedmimeinfoextensions;
+ for my $ext (@extensions) {
+ my $xext = xml_escape($ext);
+ $sharedmimeinfoextensions .= $pre.$xext.$post;
+ }
+ my $prere = $pre;
+ $prere =~ s/([\*\.])/\\\1/g;
+ my $postre = $post;
+ $postre =~ s/([\*\.])/\\\1/g;
+ $sharedmimeinfoentry =~ s/\$\$${prere}EXTENSIONS${postre}\$\$/$sharedmimeinfoextensions/gs;
+ }
+ print SMI $sharedmimeinfoentry;
+
+ my $mailcapentry = $mailcaptemplate;
+ $mailcapentry =~ s/\$\$NAME\$\$/$xname/g;
+ $mailcapentry =~ s/\$\$SHORTNAME\$\$/$xshortname/g;
+ $mailcapentry =~ s/\$\$MIMETYPE\$\$/$xmimetype/g;
+ $mailcapentry =~ s/\$\$ICONFILE\$\$/$xiconfile/g;
+ $mailcapentry =~ s/\$\$PRIMARY\$\$/$xprimarystring/g;
+ $mailcapentry =~ s/\$\$MACASSOCIATIONROLE\$\$/$xROLE/g;
+ $mailcapentry =~ s/\$\$EXTENSION\$\$/$extension0/g;
+ $mailcapentry =~ s/\$\$PRIORITY\$\$/$priority/g;
+
+ my $ext = join(",",sort(@extensions));
+ my $xdisplayext = xml_escape(join(", ", map(".$_",sort(@extensions))));
+ my $progresspercent = int(($mailcapcount/$num)*100);
+ $progresspercent = 100 if $progresspercent > 100;
+ $mailcapcount++;
+ my $xext = xml_escape($ext);
+ my $addunixextension = "true";
+
+ $mailcapentry =~ s/\$\$ADDUNIXEXTENSION\$\$/$addunixextension/g;
+ $mailcapentry =~ s/\$\$EXTENSION\$\$/$xext/g;
+ $mailcapentry =~ s/\$\$DISPLAYEXTENSION\$\$/$xdisplayext/g;
+ $mailcapentry =~ s/\$\$PROGRESSPERCENT\$\$/$progresspercent/g;
+ $mailcapentry =~ s/\$\$ID\$\$/$id/g;
+ $id++;
+ $mailcapentry =~ s/\$\$ID1\$\$/$id/g;
+ $id++;
+ $mailcapentry =~ s/\$\$ID2\$\$/$id/g;
+ $id++;
+
+ print MCA $mailcapentry;
+
+ delete $all_associations{$shortname};
+ warn("Writing entry for $name (".join(",",@$extensions).": $mimetype)\n");
+}
+
+print SMI "</mime-info>\n";
+
+close(MCA);
+close(SMI);
+
+open(D,">$desktopfile") or die ("Could not open '$desktopfile' for writing");
+print D qq([Desktop Entry]
+Version=1.1
+Type=Application
+Name=Jalview
+Comment=Multiple Sequence Alignment Editor
+Icon=jalview-icon
+Type=Application
+TryExec=jalview
+Exec=jalview -open %u
+Terminal=false
+Categories=Science;Biology;
+Keywords=alignment;sequence;
+MimeType=${MimeType}
+);
+close(D);
+
+sub xml_escape {
+ my $x = shift;
+ # stolen from Pod::Simple::XMLOutStream in base distro
+ $x =~ s/([^-\n\t !\#\$\%\(\)\*\+,\.\~\/\:\;=\?\@\[\\\]\^_\`\{\|\}a-zA-Z0-9])/'&#'.(ord($1)).';'/eg;
+ return $x;
+}