Clover icon

Coverage Report

  1. Project Clover database Thu Aug 13 2020 12:04:21 BST
  2. Package jalview.ext.jmol

File JmolVsJalviewPDBParserEndToEndTest.java

 

Coverage histogram

../../../img/srcFileCovDistChart0.png
56% of files have more coverage

Code metrics

4
41
3
1
135
89
8
0.2
13.67
3
2.67

Classes

Class Line # Actions
JmolVsJalviewPDBParserEndToEndTest 46 41 8
0.00%
 

Contributing tests

No tests hitting this source file were found.

Source view

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.ext.jmol;
22   
23    import jalview.datamodel.SequenceI;
24    import jalview.gui.JvOptionPane;
25    import jalview.io.DataSourceType;
26   
27    import java.io.File;
28    import java.io.IOException;
29    import java.util.HashSet;
30    import java.util.Set;
31    import java.util.Vector;
32   
33    import org.testng.annotations.BeforeClass;
34   
35    import mc_view.PDBfile;
36   
37    /**
38    * This is not a unit test, rather it is a bulk End-to-End scan for sequences
39    * consistency for PDB files parsed with JmolParser vs. Jalview's PDBfile
40    * parser. The directory of PDB files to test must be provided in the launch
41    * args.
42    *
43    * @author tcnofoegbu
44    *
45    */
 
46    public class JmolVsJalviewPDBParserEndToEndTest
47    {
48   
 
49  0 toggle @BeforeClass(alwaysRun = true)
50    public void setUpJvOptionPane()
51    {
52  0 JvOptionPane.setInteractiveMode(false);
53  0 JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
54    }
55   
56    /**
57    *
58    * @param args
59    * @j2sIgnore
60    */
 
61  0 toggle public static void main(String[] args)
62    {
63  0 if (args == null || args[0] == null)
64    {
65  0 System.err
66    .println("You must provide a PDB directory in the launch argument");
67  0 return;
68    }
69   
70    // args[0] must provide the directory of PDB files to run the test with
71  0 String testDir = args[0];
72  0 System.out.println("PDB directory : " + testDir);
73  0 File pdbDir = new File(testDir);
74  0 String testFiles[] = pdbDir.list();
75  0 testFileParser(testDir, testFiles);
76    }
77   
 
78  0 toggle public static void testFileParser(String testDir, String[] testFiles)
79    {
80  0 Set<String> failedFiles = new HashSet<>();
81  0 int totalSeqScanned = 0, totalFail = 0;
82  0 for (String pdbStr : testFiles)
83    {
84  0 String testFile = testDir + "/" + pdbStr;
85  0 PDBfile mctest = null;
86  0 JmolParser jtest = null;
87  0 try
88    {
89  0 mctest = new PDBfile(false, false, false, testFile, DataSourceType.FILE);
90  0 jtest = new JmolParser(testFile, DataSourceType.FILE);
91    } catch (IOException e)
92    {
93  0 System.err.println("Exception thrown while parsing : " + pdbStr);
94    }
95  0 Vector<SequenceI> seqs = jtest.getSeqs();
96  0 Vector<SequenceI> mcseqs = mctest.getSeqs();
97   
98  0 for (SequenceI sq : seqs)
99    {
100  0 try
101    {
102  0 String testSeq = mcseqs.remove(0).getSequenceAsString();
103  0 if (!sq.getSequenceAsString().equals(testSeq))
104    {
105  0 ++totalFail;
106  0 System.err.println("Test Failed for " + pdbStr + ". Diff:");
107  0 System.err.println(sq.getSequenceAsString());
108  0 System.err.println(testSeq);
109  0 failedFiles.add(pdbStr);
110    }
111  0 ++totalSeqScanned;
112    } catch (Exception e)
113    {
114  0 e.printStackTrace();
115    }
116    }
117    }
118  0 int count = 0;
119   
120  0 System.out.println("\n\nTotal sequence Scanned : " + totalSeqScanned);
121  0 System.out.println("Total sequence passed : "
122    + (totalSeqScanned - totalFail));
123  0 System.out.println("Total sequence failed : " + totalFail);
124  0 System.out
125    .println("Success rate: "
126    + ((totalSeqScanned - totalFail) * 100)
127    / totalSeqScanned + "%");
128  0 System.out.println("\nList of " + failedFiles.size()
129    + " file(s) with sequence diffs:");
130  0 for (String problemFile : failedFiles)
131    {
132  0 System.out.println(++count + ". " + problemFile);
133    }
134    }
135    }