JAL-653 JAL-1780 refactor getGroups so HTMLfile/JSONfile adopt same pattern as other...
[jalview.git] / src / jalview / io / AppletFormatAdapter.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3  * Copyright (C) $$Year-Rel$$ The Jalview Authors
4  *
5  * This file is part of Jalview.
6  *
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.
11  *
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.
16  *
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.
20  */
21 package jalview.io;
22
23 import jalview.api.AlignViewportI;
24 import jalview.datamodel.Alignment;
25 import jalview.datamodel.AlignmentAnnotation;
26 import jalview.datamodel.AlignmentI;
27 import jalview.datamodel.AlignmentView;
28 import jalview.util.MessageManager;
29
30 import java.io.File;
31 import java.io.InputStream;
32 import java.util.List;
33
34 /**
35  * A low level class for alignment and feature IO with alignment formatting
36  * methods used by both applet and application for generating flat alignment
37  * files. It also holds the lists of magic format names that the applet and
38  * application will allow the user to read or write files with.
39  *
40  * @author $author$
41  * @version $Revision$
42  */
43 public class AppletFormatAdapter
44 {
45   private AlignViewportI viewport;
46
47   public static String FILE = "File";
48
49   public static String URL = "URL";
50
51   public static String PASTE = "Paste";
52
53   public static String CLASSLOADER = "ClassLoader";
54
55   /**
56    * add jalview-derived non-secondary structure annotation from PDB structure
57    */
58   boolean annotFromStructure = false;
59
60   /**
61    * add secondary structure from PDB data with built-in algorithms
62    */
63   boolean localSecondaryStruct = false;
64
65   /**
66    * process PDB data with web services
67    */
68   boolean serviceSecondaryStruct = false;
69
70   private AlignFile alignFile = null;
71
72   String inFile;
73
74   /**
75    * character used to write newlines
76    */
77   protected String newline = System.getProperty("line.separator");
78
79   /**
80    * List of valid format strings used in the isValidFormat method
81    */
82   public static final String[] READABLE_FORMATS = new String[]
83   { "BLC", "CLUSTAL", "FASTA", "MSF", "PileUp", "PIR", "PFAM", "STH",
84       "PDB", "JnetFile", "RNAML", PhylipFile.FILE_DESC, JSONFile.FILE_DESC, IdentifyFile.GFF3File,
85       "HTML" };
86
87   /**
88    * List of readable format file extensions by application in order
89    * corresponding to READABLE_FNAMES
90    */
91   public static final String[] READABLE_EXTENSIONS = new String[]
92   { "fa, fasta, mfa, fastq", "aln", "pfam", "msf", "pir", "blc", "amsa",
93       "sto,stk", "xml,rnaml", PhylipFile.FILE_EXT, JSONFile.FILE_EXT,
94       ".gff2,gff3",
95       "jar,jvp", HtmlFile.FILE_EXT };
96
97   /**
98    * List of readable formats by application in order corresponding to
99    * READABLE_EXTENSIONS
100    */
101   public static final String[] READABLE_FNAMES = new String[]
102   { "Fasta", "Clustal", "PFAM", "MSF", "PIR", "BLC", "AMSA", "Stockholm",
103       "RNAML", PhylipFile.FILE_DESC, JSONFile.FILE_DESC, IdentifyFile.GFF3File, "Jalview",
104       HtmlFile.FILE_DESC };
105
106   /**
107    * List of valid format strings for use by callers of the formatSequences
108    * method
109    */
110   public static final String[] WRITEABLE_FORMATS = new String[]
111           { "BLC", "CLUSTAL", "FASTA", "MSF", "PileUp", "PIR", "PFAM", "AMSA",
112     "STH", PhylipFile.FILE_DESC, JSONFile.FILE_DESC };
113
114   /**
115    * List of extensions corresponding to file format types in WRITABLE_FNAMES
116    * that are writable by the application.
117    */
118   public static final String[] WRITABLE_EXTENSIONS = new String[]
119   { "fa, fasta, mfa, fastq", "aln", "pfam", "msf", "pir", "blc", "amsa",
120       "sto,stk", PhylipFile.FILE_EXT, JSONFile.FILE_EXT, "jvp" };
121
122   /**
123    * List of writable formats by the application. Order must correspond with the
124    * WRITABLE_EXTENSIONS list of formats.
125    */
126   public static final String[] WRITABLE_FNAMES = new String[]
127   { "Fasta", "Clustal", "PFAM", "MSF", "PIR", "BLC", "AMSA", "STH",
128       PhylipFile.FILE_DESC, JSONFile.FILE_DESC, "Jalview" };
129
130   public static String INVALID_CHARACTERS = "Contains invalid characters";
131
132   // TODO: make these messages dynamic
133   public static String SUPPORTED_FORMATS = "Formats currently supported are\n"
134           + prettyPrint(READABLE_FORMATS);
135
136   public AppletFormatAdapter()
137   {
138   }
139
140   public AppletFormatAdapter(AlignViewportI viewport)
141   {
142     this.viewport = viewport;
143   }
144
145   /**
146    *
147    * @param els
148    * @return grammatically correct(ish) list consisting of els elements.
149    */
150   public static String prettyPrint(String[] els)
151   {
152     StringBuffer list = new StringBuffer();
153     for (int i = 0, iSize = els.length - 1; i < iSize; i++)
154     {
155       list.append(els[i]);
156       list.append(", ");
157     }
158     list.append(" and " + els[els.length - 1] + ".");
159     return list.toString();
160   }
161
162
163   public void setNewlineString(String nl)
164   {
165     newline = nl;
166   }
167
168   public String getNewlineString()
169   {
170     return newline;
171   }
172
173   /**
174    * check that this format is valid for reading
175    *
176    * @param format
177    *          a format string to be compared with READABLE_FORMATS
178    * @return true if format is readable
179    */
180   public static final boolean isValidFormat(String format)
181   {
182     return isValidFormat(format, false);
183   }
184
185   /**
186    * validate format is valid for IO
187    *
188    * @param format
189    *          a format string to be compared with either READABLE_FORMATS or
190    *          WRITEABLE_FORMATS
191    * @param forwriting
192    *          when true, format is checked for containment in WRITEABLE_FORMATS
193    * @return true if format is valid
194    */
195   public static final boolean isValidFormat(String format,
196           boolean forwriting)
197   {
198     boolean valid = false;
199     String[] format_list = (forwriting) ? WRITEABLE_FORMATS
200             : READABLE_FORMATS;
201     for (String element : format_list)
202     {
203       if (element.equalsIgnoreCase(format))
204       {
205         return true;
206       }
207     }
208
209     return valid;
210   }
211
212   /**
213    * Constructs the correct filetype parser for a characterised datasource
214    *
215    * @param inFile
216    *          data/data location
217    * @param type
218    *          type of datasource
219    * @param format
220    *          File format of data provided by datasource
221    *
222    * @return DOCUMENT ME!
223    */
224   public Alignment readFile(String inFile, String type, String format)
225           throws java.io.IOException
226   {
227     // TODO: generalise mapping between format string and io. class instances
228     // using Constructor.invoke reflection
229     this.inFile = inFile;
230     try
231     {
232       Alignment al;
233       if (format.equals("FASTA"))
234       {
235         alignFile = new FastaFile(inFile, type);
236       }
237       else if (format.equals("MSF"))
238       {
239         alignFile = new MSFfile(inFile, type);
240       }
241       else if (format.equals("PileUp"))
242       {
243         alignFile = new PileUpfile(inFile, type);
244       }
245       else if (format.equals("CLUSTAL"))
246       {
247         alignFile = new ClustalFile(inFile, type);
248       }
249       else if (format.equals("BLC"))
250       {
251         alignFile = new BLCFile(inFile, type);
252       }
253       else if (format.equals("PIR"))
254       {
255         alignFile = new PIRFile(inFile, type);
256       }
257       else if (format.equals("PFAM"))
258       {
259         alignFile = new PfamFile(inFile, type);
260       }
261       else if (format.equals("JnetFile"))
262       {
263         alignFile = new JPredFile(inFile, type);
264         ((JPredFile) alignFile).removeNonSequences();
265       }
266       else if (format.equals("PDB"))
267       {
268         alignFile = new MCview.PDBfile(annotFromStructure,
269                 localSecondaryStruct, serviceSecondaryStruct, inFile, type);
270         // Uncomment to test Jmol data based PDB processing: JAL-1213
271         // afile = new jalview.ext.jmol.PDBFileWithJmol(inFile, type);
272       }
273       else if (format.equals("STH"))
274       {
275         alignFile = new StockholmFile(inFile, type);
276       }
277       else if (format.equals("SimpleBLAST"))
278       {
279         alignFile = new SimpleBlastFile(inFile, type);
280       }
281       else if (format.equals(PhylipFile.FILE_DESC))
282       {
283         alignFile = new PhylipFile(inFile, type);
284       }
285       else if (format.equals(JSONFile.FILE_DESC))
286       {
287         alignFile = new JSONFile(inFile, type);
288       }
289       else if (format.equals(HtmlFile.FILE_DESC))
290       {
291         alignFile = new HtmlFile(inFile, type);
292       }
293       else if (format.equals("RNAML"))
294       {
295         alignFile = new RnamlFile(inFile, type);
296       }
297       else if (format.equals(IdentifyFile.GFF3File))
298       {
299         alignFile = new Gff3File(inFile, type);
300       }
301       // Standard boilerplate for creating alignment from parser
302       alignFile.setViewport(viewport);
303       
304       al = new Alignment(alignFile.getSeqsAsArray());
305
306       alignFile.addAnnotations(al);
307
308       alignFile.addGroups(al);
309
310       return al;
311     } catch (Exception e)
312     {
313       e.printStackTrace();
314       System.err.println("Failed to read alignment using the '" + format
315               + "' reader.\n" + e);
316
317       if (e.getMessage() != null
318               && e.getMessage().startsWith(INVALID_CHARACTERS))
319       {
320         throw new java.io.IOException(e.getMessage());
321       }
322
323       // Finally test if the user has pasted just the sequence, no id
324       if (type.equalsIgnoreCase("Paste"))
325       {
326         try
327         {
328           // Possible sequence is just residues with no label
329           alignFile = new FastaFile(">UNKNOWN\n" + inFile, "Paste");
330           Alignment al = new Alignment(alignFile.getSeqsAsArray());
331
332           alignFile.addSeqGroups(al);
333           alignFile.addAnnotations(al);
334           return al;
335
336         } catch (Exception ex)
337         {
338           if (ex.toString().startsWith(INVALID_CHARACTERS))
339           {
340             throw new java.io.IOException(e.getMessage());
341           }
342
343           ex.printStackTrace();
344         }
345       }
346
347       // If we get to this stage, the format was not supported
348       throw new java.io.IOException(SUPPORTED_FORMATS);
349     }
350   }
351
352   /**
353    * Constructs the correct filetype parser for an already open datasource
354    *
355    * @param source
356    *          an existing datasource
357    * @param format
358    *          File format of data that will be provided by datasource
359    *
360    * @return DOCUMENT ME!
361    */
362   public AlignmentI readFromFile(FileParse source, String format)
363           throws java.io.IOException
364   {
365     // TODO: generalise mapping between format string and io. class instances
366     // using Constructor.invoke reflection
367     // This is exactly the same as the readFile method except we substitute
368     // 'inFile, type' with 'source'
369     this.inFile = source.getInFile();
370     String type = source.type;
371     try
372     {
373       Alignment al;
374       if (format.equals("FASTA"))
375       {
376         alignFile = new FastaFile(source);
377       }
378       else if (format.equals("MSF"))
379       {
380         alignFile = new MSFfile(source);
381       }
382       else if (format.equals("PileUp"))
383       {
384         alignFile = new PileUpfile(source);
385       }
386       else if (format.equals("CLUSTAL"))
387       {
388         alignFile = new ClustalFile(source);
389       }
390       else if (format.equals("BLC"))
391       {
392         alignFile = new BLCFile(source);
393       }
394       else if (format.equals("PIR"))
395       {
396         alignFile = new PIRFile(source);
397       }
398       else if (format.equals("PFAM"))
399       {
400         alignFile = new PfamFile(source);
401       }
402       else if (format.equals("JnetFile"))
403       {
404         alignFile = new JPredFile(source);
405         ((JPredFile) alignFile).removeNonSequences();
406       }
407       else if (format.equals("PDB"))
408       {
409         alignFile = new MCview.PDBfile(annotFromStructure,
410                 localSecondaryStruct, serviceSecondaryStruct, source);
411       }
412       else if (format.equals("STH"))
413       {
414         alignFile = new StockholmFile(source);
415       }
416       else if (format.equals("RNAML"))
417       {
418         alignFile = new RnamlFile(source);
419       }
420       else if (format.equals("SimpleBLAST"))
421       {
422         alignFile = new SimpleBlastFile(source);
423       }
424       else if (format.equals(PhylipFile.FILE_DESC))
425       {
426         alignFile = new PhylipFile(source);
427       }
428       else if (format.equals(IdentifyFile.GFF3File))
429       {
430         alignFile = new Gff3File(inFile, type);
431       }
432       else if (format.equals(JSONFile.FILE_DESC))
433       {
434         alignFile = new JSONFile(source);
435         al = new Alignment(alignFile.getSeqsAsArray());
436         alignFile.addAnnotations(al);
437         alignFile.addSeqGroups(al);
438         return al;
439       }
440       else if (format.equals(HtmlFile.FILE_DESC))
441       {
442         alignFile = new HtmlFile(source);
443       }
444       al = new Alignment(alignFile.getSeqsAsArray());
445       alignFile.addAnnotations(al);
446
447       return al;
448     } catch (Exception e)
449     {
450       e.printStackTrace();
451       System.err.println("Failed to read alignment using the '" + format
452               + "' reader.\n" + e);
453
454       if (e.getMessage() != null
455               && e.getMessage().startsWith(INVALID_CHARACTERS))
456       {
457         throw new java.io.IOException(e.getMessage());
458       }
459
460       // Finally test if the user has pasted just the sequence, no id
461       if (type.equalsIgnoreCase("Paste"))
462       {
463         try
464         {
465           // Possible sequence is just residues with no label
466           alignFile = new FastaFile(">UNKNOWN\n" + inFile, "Paste");
467           Alignment al = new Alignment(alignFile.getSeqsAsArray());
468           alignFile.addAnnotations(al);
469           alignFile.addSeqGroups(al);
470           return al;
471
472         } catch (Exception ex)
473         {
474           if (ex.toString().startsWith(INVALID_CHARACTERS))
475           {
476             throw new java.io.IOException(e.getMessage());
477           }
478
479           ex.printStackTrace();
480         }
481       }
482
483       // If we get to this stage, the format was not supported
484       throw new java.io.IOException(SUPPORTED_FORMATS);
485     }
486   }
487
488
489   /**
490    * create an alignment flatfile from a Jalview alignment view
491    * @param format
492    * @param jvsuffix
493    * @param av
494    * @param selectedOnly
495    * @return flatfile in a string
496    */
497   public String formatSequences(String format, boolean jvsuffix,
498           AlignViewportI av, boolean selectedOnly)
499   {
500
501     AlignmentView selvew = av.getAlignmentView(selectedOnly, false);
502     AlignmentI aselview = selvew.getVisibleAlignment(av
503             .getGapCharacter());
504     List<AlignmentAnnotation> ala = (av
505             .getVisibleAlignmentAnnotation(selectedOnly));
506     if (ala != null)
507     {
508       for (AlignmentAnnotation aa : ala)
509       {
510         aselview.addAnnotation(aa);
511       }
512     }
513
514     return formatSequences(format, aselview, jvsuffix);
515   }
516
517   /**
518    * Construct an output class for an alignment in a particular filetype TODO:
519    * allow caller to detect errors and warnings encountered when generating
520    * output
521    *
522    * @param format
523    *          string name of alignment format
524    * @param alignment
525    *          the alignment to be written out
526    * @param jvsuffix
527    *          passed to AlnFile class controls whether /START-END is added to
528    *          sequence names
529    *
530    * @return alignment flat file contents
531    */
532   public String formatSequences(String format, AlignmentI alignment,
533           boolean jvsuffix)
534   {
535     try
536     {
537       AlignFile afile = null;
538       if (format.equalsIgnoreCase("FASTA"))
539       {
540         afile = new FastaFile();
541       }
542       else if (format.equalsIgnoreCase("MSF"))
543       {
544         afile = new MSFfile();
545       }
546       else if (format.equalsIgnoreCase("PileUp"))
547       {
548         afile = new PileUpfile();
549       }
550       else if (format.equalsIgnoreCase("CLUSTAL"))
551       {
552         afile = new ClustalFile();
553       }
554       else if (format.equalsIgnoreCase("BLC"))
555       {
556         afile = new BLCFile();
557       }
558       else if (format.equalsIgnoreCase("PIR"))
559       {
560         afile = new PIRFile();
561       }
562       else if (format.equalsIgnoreCase("PFAM"))
563       {
564         afile = new PfamFile();
565       }
566       else if (format.equalsIgnoreCase("STH"))
567       {
568         afile = new StockholmFile(alignment);
569       }
570       else if (format.equalsIgnoreCase("AMSA"))
571       {
572         afile = new AMSAFile(alignment);
573       }
574       else if (format.equalsIgnoreCase(PhylipFile.FILE_DESC))
575       {
576         afile = new PhylipFile();
577       }
578        else if (format.equalsIgnoreCase(JSONFile.FILE_DESC))
579        {
580         afile = new JSONFile();
581         afile.setViewport(viewport);
582         // Add groups to AlignFile
583         afile.seqGroups = alignment.getGroups();
584
585         // Add non auto calculated annotation to AlignFile
586         for (AlignmentAnnotation annot : alignment.getAlignmentAnnotation())
587         {
588           if (annot != null && !annot.autoCalculated)
589           {
590             if (annot.label.equals("PDB.CATempFactor"))
591             {
592               continue;
593             }
594             afile.annotations.add(annot);
595           }
596         }
597        }
598       else if (format.equalsIgnoreCase("RNAML"))
599       {
600         afile = new RnamlFile();
601       }
602
603       else
604       {
605         throw new Exception(MessageManager.getString("error.implementation_error_unknown_file_format_string"));
606       }
607       afile.setNewlineString(newline);
608       afile.addJVSuffix(jvsuffix);
609
610       afile.setSeqs(alignment.getSequencesArray());
611
612
613       String afileresp = afile.print();
614       if (afile.hasWarningMessage())
615       {
616         System.err.println("Warning raised when writing as " + format
617                 + " : " + afile.getWarningMessage());
618       }
619       return afileresp;
620     } catch (Exception e)
621     {
622       System.err.println("Failed to write alignment as a '" + format
623               + "' file\n");
624       e.printStackTrace();
625     }
626
627     return null;
628   }
629
630   public static String checkProtocol(String file)
631   {
632     String protocol = FILE;
633     String ft = file.toLowerCase().trim();
634     if (ft.indexOf("http:") == 0 || ft.indexOf("https:") == 0
635             || ft.indexOf("file:") == 0)
636     {
637       protocol = URL;
638     }
639     return protocol;
640   }
641
642   public static void main(String[] args)
643   {
644     int i = 0;
645     while (i < args.length)
646     {
647       File f = new File(args[i]);
648       if (f.exists())
649       {
650         try
651         {
652           System.out.println("Reading file: " + f);
653           AppletFormatAdapter afa = new AppletFormatAdapter();
654           Runtime r = Runtime.getRuntime();
655           System.gc();
656           long memf = -r.totalMemory() + r.freeMemory();
657           long t1 = -System.currentTimeMillis();
658           Alignment al = afa.readFile(args[i], FILE,
659                   new IdentifyFile().Identify(args[i], FILE));
660           t1 += System.currentTimeMillis();
661           System.gc();
662           memf += r.totalMemory() - r.freeMemory();
663           if (al != null)
664           {
665             System.out.println("Alignment contains " + al.getHeight()
666                     + " sequences and " + al.getWidth() + " columns.");
667             try
668             {
669               System.out.println(new AppletFormatAdapter().formatSequences(
670                       "FASTA", al, true));
671             } catch (Exception e)
672             {
673               System.err
674               .println("Couln't format the alignment for output as a FASTA file.");
675               e.printStackTrace(System.err);
676             }
677           }
678           else
679           {
680             System.out.println("Couldn't read alignment");
681           }
682           System.out.println("Read took " + (t1 / 1000.0) + " seconds.");
683           System.out
684           .println("Difference between free memory now and before is "
685                   + (memf / (1024.0 * 1024.0) * 1.0) + " MB");
686         } catch (Exception e)
687         {
688           System.err.println("Exception when dealing with " + i
689                   + "'th argument: " + args[i] + "\n" + e);
690         }
691       }
692       else
693       {
694         System.err.println("Ignoring argument '" + args[i] + "' (" + i
695                 + "'th)- not a readable file.");
696       }
697       i++;
698     }
699   }
700
701   /**
702    * try to discover how to access the given file as a valid datasource that
703    * will be identified as the given type.
704    *
705    * @param file
706    * @param format
707    * @return protocol that yields the data parsable as the given type
708    */
709   public static String resolveProtocol(String file, String format)
710   {
711     return resolveProtocol(file, format, false);
712   }
713
714   public static String resolveProtocol(String file, String format,
715           boolean debug)
716   {
717     // TODO: test thoroughly!
718     String protocol = null;
719     if (debug)
720     {
721       System.out.println("resolving datasource started with:\n>>file\n"
722               + file + ">>endfile");
723     }
724
725     // This might throw a security exception in certain browsers
726     // Netscape Communicator for instance.
727     try
728     {
729       boolean rtn = false;
730       InputStream is = System.getSecurityManager().getClass()
731               .getResourceAsStream("/" + file);
732       if (is != null)
733       {
734         rtn = true;
735         is.close();
736       }
737       if (debug)
738       {
739         System.err.println("Resource '" + file + "' was "
740                 + (rtn ? "" : "not") + " located by classloader.");
741       }
742       ;
743       if (rtn)
744       {
745         protocol = AppletFormatAdapter.CLASSLOADER;
746       }
747
748     } catch (Exception ex)
749     {
750       System.err
751       .println("Exception checking resources: " + file + " " + ex);
752     }
753
754     if (file.indexOf("://") > -1)
755     {
756       protocol = AppletFormatAdapter.URL;
757     }
758     else
759     {
760       // skipping codebase prepend check.
761       protocol = AppletFormatAdapter.FILE;
762     }
763     FileParse fp = null;
764     try
765     {
766       if (debug)
767       {
768         System.out.println("Trying to get contents of resource as "
769                 + protocol + ":");
770       }
771       fp = new FileParse(file, protocol);
772       if (!fp.isValid())
773       {
774         fp = null;
775       }
776       else
777       {
778         if (debug)
779         {
780           System.out.println("Successful.");
781         }
782       }
783     } catch (Exception e)
784     {
785       if (debug)
786       {
787         System.err.println("Exception when accessing content: " + e);
788       }
789       fp = null;
790     }
791     if (fp == null)
792     {
793       if (debug)
794       {
795         System.out.println("Accessing as paste.");
796       }
797       protocol = AppletFormatAdapter.PASTE;
798       fp = null;
799       try
800       {
801         fp = new FileParse(file, protocol);
802         if (!fp.isValid())
803         {
804           fp = null;
805         }
806       } catch (Exception e)
807       {
808         System.err.println("Failed to access content as paste!");
809         e.printStackTrace();
810         fp = null;
811       }
812     }
813     if (fp == null)
814     {
815       return null;
816     }
817     if (format == null || format.length() == 0)
818     {
819       return protocol;
820     }
821     else
822     {
823       try
824       {
825         String idformat = new jalview.io.IdentifyFile().Identify(file,
826                 protocol);
827         if (idformat == null)
828         {
829           if (debug)
830           {
831             System.out.println("Format not identified. Inaccessible file.");
832           }
833           return null;
834         }
835         if (debug)
836         {
837           System.out.println("Format identified as " + idformat
838                   + "and expected as " + format);
839         }
840         if (idformat.equals(format))
841         {
842           if (debug)
843           {
844             System.out.println("Protocol identified as " + protocol);
845           }
846           return protocol;
847         }
848         else
849         {
850           if (debug)
851           {
852             System.out
853             .println("File deemed not accessible via " + protocol);
854           }
855           fp.close();
856           return null;
857         }
858       } catch (Exception e)
859       {
860         if (debug)
861         {
862           System.err.println("File deemed not accessible via " + protocol);
863           e.printStackTrace();
864         }
865         ;
866
867       }
868     }
869     return null;
870   }
871
872   public AlignFile getAlignFile()
873   {
874     return alignFile;
875   }
876
877   public void setAlignFile(AlignFile alignFile)
878   {
879     this.alignFile = alignFile;
880   }
881 }