Clover icon

Coverage Report

  1. Project Clover database Mon Nov 11 2024 17:27:16 GMT
  2. Package jalview.gui.structurechooser

File StructureChooserQuerySourceTest.java

 

Code metrics

6
126
8
1
540
401
12
0.1
15.75
8
1.5

Classes

Class Line # Actions
StructureChooserQuerySourceTest 56 126 12
0.9857142698.6%
 

Contributing tests

This file is covered by 9 tests. .

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.gui.structurechooser;
22   
23    import static org.testng.Assert.assertEquals;
24    import static org.testng.Assert.assertTrue;
25    import static org.testng.Assert.fail;
26   
27    import java.util.ArrayList;
28    import java.util.List;
29    import java.util.Vector;
30   
31    import org.junit.Assert;
32    import org.testng.AssertJUnit;
33    import org.testng.annotations.AfterMethod;
34    import org.testng.annotations.BeforeClass;
35    import org.testng.annotations.BeforeMethod;
36    import org.testng.annotations.DataProvider;
37    import org.testng.annotations.Test;
38   
39    import jalview.datamodel.DBRefEntry;
40    import jalview.datamodel.DBRefSource;
41    import jalview.datamodel.PDBEntry;
42    import jalview.datamodel.Sequence;
43    import jalview.datamodel.SequenceI;
44    import jalview.fts.api.FTSData;
45    import jalview.fts.api.FTSDataColumnI;
46    import jalview.fts.core.FTSRestRequest;
47    import jalview.fts.core.FTSRestResponse;
48    import jalview.fts.service.pdb.PDBFTSRestClientTest;
49    import jalview.fts.service.threedbeacons.TDB_FTSData;
50    import jalview.fts.service.threedbeacons.TDBeaconsFTSRestClient;
51    import jalview.fts.threedbeacons.TDBeaconsFTSRestClientTest;
52    import jalview.gui.JvOptionPane;
53    import jalview.gui.StructureChooser;
54    import jalview.jbgui.FilterOption;
55   
 
56    public class StructureChooserQuerySourceTest
57    {
58   
 
59  1 toggle @BeforeClass(alwaysRun = true)
60    public void setUpJvOptionPane()
61    {
62  1 JvOptionPane.setInteractiveMode(false);
63  1 JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
64    }
65   
66    Sequence seq, upSeq, upSeq_insulin, upSeq_r1ab;
67   
68    private Sequence upSeq_fer1_maize;
69   
70    private Sequence upSeq_epas1_human;
71   
72    // same set up as for structurechooser test
73   
 
74  9 toggle @BeforeMethod(alwaysRun = true)
75    public void setUp() throws Exception
76    {
77  9 seq = new Sequence("PDB|4kqy|4KQY|A", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", 1,
78    26);
79  9 seq.createDatasetSequence();
80  45 for (int x = 1; x < 5; x++)
81    {
82  36 DBRefEntry dbRef = new DBRefEntry();
83  36 dbRef.setAccessionId("XYZ_" + x);
84  36 seq.addDBRef(dbRef);
85    }
86   
87  9 PDBEntry dbRef = new PDBEntry();
88  9 dbRef.setId("1tim");
89   
90  9 Vector<PDBEntry> pdbIds = new Vector<>();
91  9 pdbIds.add(dbRef);
92   
93  9 seq.setPDBId(pdbIds);
94   
95    // Uniprot sequence for 3D-Beacons mocks
96  9 upSeq = new Sequence("P38398",
97    "MDLSALRVEEVQNVINAMQKILECPICLELIKEPVSTKCDHIFCKFCMLKLLNQKKGPSQCPLCKNDITKRS\n"
98    + "LQESTRFSQLVEELLKIICAFQLDTGLEYANSYNFAKKENNSPEHLKDEVSIIQSMGYRNRAKRLLQSEPEN\n"
99    + "PSLQETSLSVQLSNLGTVRTLRTKQRIQPQKTSVYIELGSDSSEDTVNKATYCSVGDQELLQITPQGTRDEI\n"
100    + "SLDSAKKAACEFSETDVTNTEHHQPSNNDLNTTEKRAAERHPEKYQGSSVSNLHVEPCGTNTHASSLQHENS\n"
101    + "SLLLTKDRMNVEKAEFCNKSKQPGLARSQHNRWAGSKETCNDRRTPSTEKKVDLNADPLCERKEWNKQKLPC\n"
102    + "SENPRDTEDVPWITLNSSIQKVNEWFSRSDELLGSDDSHDGESESNAKVADVLDVLNEVDEYSGSSEKIDLL\n"
103    + "ASDPHEALICKSERVHSKSVESNIEDKIFGKTYRKKASLPNLSHVTENLIIGAFVTEPQIIQERPLTNKLKR\n"
104    + "KRRPTSGLHPEDFIKKADLAVQKTPEMINQGTNQTEQNGQVMNITNSGHENKTKGDSIQNEKNPNPIESLEK\n"
105    + "ESAFKTKAEPISSSISNMELELNIHNSKAPKKNRLRRKSSTRHIHALELVVSRNLSPPNCTELQIDSCSSSE\n"
106    + "EIKKKKYNQMPVRHSRNLQLMEGKEPATGAKKSNKPNEQTSKRHDSDTFPELKLTNAPGSFTKCSNTSELKE\n"
107    + "FVNPSLPREEKEEKLETVKVSNNAEDPKDLMLSGERVLQTERSVESSSISLVPGTDYGTQESISLLEVSTLG\n"
108    + "KAKTEPNKCVSQCAAFENPKGLIHGCSKDNRNDTEGFKYPLGHEVNHSRETSIEMEESELDAQYLQNTFKVS\n"
109    + "KRQSFAPFSNPGNAEEECATFSAHSGSLKKQSPKVTFECEQKEENQGKNESNIKPVQTVNITAGFPVVGQKD\n"
110    + "KPVDNAKCSIKGGSRFCLSSQFRGNETGLITPNKHGLLQNPYRIPPLFPIKSFVKTKCKKNLLEENFEEHSM\n"
111    + "SPEREMGNENIPSTVSTISRNNIRENVFKEASSSNINEVGSSTNEVGSSINEIGSSDENIQAELGRNRGPKL\n"
112    + "NAMLRLGVLQPEVYKQSLPGSNCKHPEIKKQEYEEVVQTVNTDFSPYLISDNLEQPMGSSHASQVCSETPDD\n"
113    + "LLDDGEIKEDTSFAENDIKESSAVFSKSVQKGELSRSPSPFTHTHLAQGYRRGAKKLESSEENLSSEDEELP\n"
114    + "CFQHLLFGKVNNIPSQSTRHSTVATECLSKNTEENLLSLKNSLNDCSNQVILAKASQEHHLSEETKCSASLF\n"
115    + "SSQCSELEDLTANTNTQDPFLIGSSKQMRHQSESQGVGLSDKELVSDDEERGTGLEENNQEEQSMDSNLGEA\n"
116    + "ASGCESETSVSEDCSGLSSQSDILTTQQRDTMQHNLIKLQQEMAELEAVLEQHGSQPSNSYPSIISDSSALE\n"
117    + "DLRNPEQSTSEKAVLTSQKSSEYPISQNPEGLSADKFEVSADSSTSKNKEPGVERSSPSKCPSLDDRWYMHS\n"
118    + "CSGSLQNRNYPSQEELIKVVDVEEQQLEESGPHDLTETSYLPRQDLEGTPYLESGISLFSDDPESDPSEDRA\n"
119    + "PESARVGNIPSSTSALKVPQLKVAESAQSPAAAHTTDTAGYNAMEESVSREKPELTASTERVNKRMSMVVSG\n"
120    + "LTPEEFMLVYKFARKHHITLTNLITEETTHVVMKTDAEFVCERTLKYFLGIAGGKWVVSYFWVTQSIKERKM\n"
121    + "LNEHDFEVRGDVVNGRNHQGPKRARESQDRKIFRGLEICCYGPFTNMPTDQLEWMVQLCGASVVKELSSFTL\n"
122    + "GTGVHPIVVVQPDAWTEDNGFHAIGQMCEAPVVTREWVLDSVALYQCQELDTYLIPQIPHSHY\n"
123    + "",
124    1, 1863);
125  9 upSeq.createDatasetSequence();
126  9 upSeq.setDescription("Breast cancer type 1 susceptibility protein");
127  9 upSeq.addDBRef(new DBRefEntry("UNIPROT", "0", "P38398", null, true));
128   
129  9 upSeq_insulin = new Sequence("INS_HUMAN",
130    "MALWMRLLPLLALLALWGPDPAAAFVNQHLCGSHLVEALYLVCGERGFFYTPKTRREAEDLQVGQVELGGGP"
131    + "GAGSLQPLALEGSLQKRGIVEQCCTSICSLYQLENYCN");
132  9 upSeq_insulin.createDatasetSequence();
133  9 upSeq_insulin.setDescription("Insulin");
134  9 upSeq_insulin
135    .addDBRef(new DBRefEntry("UNIPROT", "0", "P01308", null, true));
136   
137  9 upSeq_r1ab = new Sequence("R1AB_SARS2",
138    "MESLVPGFNEKTHVQLSLPVLQVRDVLVRGFGDSVEEVLSEARQHLKDGTCGLVEVEKGVLPQLEQPYVFIK\n"
139    + "RSDARTAPHGHVMVELVAELEGIQYGRSGETLGVLVPHVGEIPVAYRKVLLRKNGNKGAGGHSYGADLKSFD\n"
140    + "LGDELGTDPYEDFQENWNTKHSSGVTRELMRELNGGAYTRYVDNNFCGPDGYPLECIKDLLARAGKASCTLS\n"
141    + "EQLDFIDTKRGVYCCREHEHEIAWYTERSEKSYELQTPFEIKLAKKFDTFNGECPNFVFPLNSIIKTIQPRV\n"
142    + "EKKKLDGFMGRIRSVYPVASPNECNQMCLSTLMKCDHCGETSWQTGDFVKATCEFCGTENLTKEGATTCGYL\n"
143    + "PQNAVVKIYCPACHNSEVGPEHSLAEYHNESGLKTILRKGGRTIAFGGCVFSYVGCHNKCAYWVPRASANIG\n"
144    + "CNHTGVVGEGSEGLNDNLLEILQKEKVNINIVGDFKLNEEIAIILASFSASTSAFVETVKGLDYKAFKQIVE\n"
145    + "SCGNFKVTKGKAKKGAWNIGEQKSILSPLYAFASEAARVVRSIFSRTLETAQNSVRVLQKAAITILDGISQY\n"
146    + "SLRLIDAMMFTSDLATNNLVVMAYITGGVVQLTSQWLTNIFGTVYEKLKPVLDWLEEKFKEGVEFLRDGWEI\n"
147    + "VKFISTCACEIVGGQIVTCAKEIKESVQTFFKLVNKFLALCADSIIIGGAKLKALNLGETFVTHSKGLYRKC\n"
148    + "VKSREETGLLMPLKAPKEIIFLEGETLPTEVLTEEVVLKTGDLQPLEQPTSEAVEAPLVGTPVCINGLMLLE\n"
149    + "IKDTEKYCALAPNMMVTNNTFTLKGGAPTKVTFGDDTVIEVQGYKSVNITFELDERIDKVLNEKCSAYTVEL\n"
150    + "GTEVNEFACVVADAVIKTLQPVSELLTPLGIDLDEWSMATYYLFDESGEFKLASHMYCSFYPPDEDEEEGDC\n"
151    + "EEEEFEPSTQYEYGTEDDYQGKPLEFGATSAALQPEEEQEEDWLDDDSQQTVGQQDGSEDNQTTTIQTIVEV\n"
152    + "QPQLEMELTPVVQTIEVNSFSGYLKLTDNVYIKNADIVEEAKKVKPTVVVNAANVYLKHGGGVAGALNKATN\n"
153    + "NAMQVESDDYIATNGPLKVGGSCVLSGHNLAKHCLHVVGPNVNKGEDIQLLKSAYENFNQHEVLLAPLLSAG\n"
154    + "IFGADPIHSLRVCVDTVRTNVYLAVFDKNLYDKLVSSFLEMKSEKQVEQKIAEIPKEEVKPFITESKPSVEQ\n"
155    + "RKQDDKKIKACVEEVTTTLEETKFLTENLLLYIDINGNLHPDSATLVSDIDITFLKKDAPYIVGDVVQEGVL\n"
156    + "TAVVIPTKKAGGTTEMLAKALRKVPTDNYITTYPGQGLNGYTVEEAKTVLKKCKSAFYILPSIISNEKQEIL\n"
157    + "GTVSWNLREMLAHAEETRKLMPVCVETKAIVSTIQRKYKGIKIQEGVVDYGARFYFYTSKTTVASLINTLND\n"
158    + "LNETLVTMPLGYVTHGLNLEEAARYMRSLKVPATVSVSSPDAVTAYNGYLTSSSKTPEEHFIETISLAGSYK\n"
159    + "DWSYSGQSTQLGIEFLKRGDKSVYYTSNPTTFHLDGEVITFDNLKTLLSLREVRTIKVFTTVDNINLHTQVV\n"
160    + "DMSMTYGQQFGPTYLDGADVTKIKPHNSHEGKTFYVLPNDDTLRVEAFEYYHTTDPSFLGRYMSALNHTKKW\n"
161    + "KYPQVNGLTSIKWADNNCYLATALLTLQQIELKFNPPALQDAYYRARAGEAANFCALILAYCNKTVGELGDV\n"
162    + "RETMSYLFQHANLDSCKRVLNVVCKTCGQQQTTLKGVEAVMYMGTLSYEQFKKGVQIPCTCGKQATKYLVQQ\n"
163    + "ESPFVMMSAPPAQYELKHGTFTCASEYTGNYQCGHYKHITSKETLYCIDGALLTKSSEYKGPITDVFYKENS\n"
164    + "YTTTIKPVTYKLDGVVCTEIDPKLDNYYKKDNSYFTEQPIDLVPNQPYPNASFDNFKFVCDNIKFADDLNQL\n"
165    + "TGYKKPASRELKVTFFPDLNGDVVAIDYKHYTPSFKKGAKLLHKPIVWHVNNATNKATYKPNTWCIRCLWST\n"
166    + "KPVETSNSFDVLKSEDAQGMDNLACEDLKPVSEEVVENPTIQKDVLECNVKTTEVVGDIILKPANNSLKITE\n"
167    + "EVGHTDLMAAYVDNSSLTIKKPNELSRVLGLKTLATHGLAAVNSVPWDTIANYAKPFLNKVVSTTTNIVTRC\n"
168    + "LNRVCTNYMPYFFTLLLQLCTFTRSTNSRIKASMPTTIAKNTVKSVGKFCLEASFNYLKSPNFSKLINIIIW\n"
169    + "FLLLSVCLGSLIYSTAALGVLMSNLGMPSYCTGYREGYLNSTNVTIATYCTGSIPCSVCLSGLDSLDTYPSL\n"
170    + "ETIQITISSFKWDLTAFGLVAEWFLAYILFTRFFYVLGLAAIMQLFFSYFAVHFISNSWLMWLIINLVQMAP\n"
171    + "ISAMVRMYIFFASFYYVWKSYVHVVDGCNSSTCMMCYKRNRATRVECTTIVNGVRRSFYVYANGGKGFCKLH\n"
172    + "NWNCVNCDTFCAGSTFISDEVARDLSLQFKRPINPTDQSSYIVDSVTVKNGSIHLYFDKAGQKTYERHSLSH\n"
173    + "FVNLDNLRANNTKGSLPINVIVFDGKSKCEESSAKSASVYYSQLMCQPILLLDQALVSDVGDSAEVAVKMFD\n"
174    + "AYVNTFSSTFNVPMEKLKTLVATAEAELAKNVSLDNVLSTFISAARQGFVDSDVETKDVVECLKLSHQSDIE\n"
175    + "VTGDSCNNYMLTYNKVENMTPRDLGACIDCSARHINAQVAKSHNIALIWNVKDFMSLSEQLRKQIRSAAKKN\n"
176    + "NLPFKLTCATTRQVVNVVTTKIALKGGKIVNNWLKQLIKVTLVFLFVAAIFYLITPVHVMSKHTDFSSEIIG\n"
177    + "YKAIDGGVTRDIASTDTCFANKHADFDTWFSQRGGSYTNDKACPLIAAVITREVGFVVPGLPGTILRTTNGD\n"
178    + "FLHFLPRVFSAVGNICYTPSKLIEYTDFATSACVLAAECTIFKDASGKPVPYCYDTNVLEGSVAYESLRPDT\n"
179    + "RYVLMDGSIIQFPNTYLEGSVRVVTTFDSEYCRHGTCERSEAGVCVSTSGRWVLNNDYYRSLPGVFCGVDAV\n"
180    + "NLLTNMFTPLIQPIGALDISASIVAGGIVAIVVTCLAYYFMRFRRAFGEYSHVVAFNTLLFLMSFTVLCLTP\n"
181    + "VYSFLPGVYSVIYLYLTFYLTNDVSFLAHIQWMVMFTPLVPFWITIAYIICISTKHFYWFFSNYLKRRVVFN\n"
182    + "GVSFSTFEEAALCTFLLNKEMYLKLRSDVLLPLTQYNRYLALYNKYKYFSGAMDTTSYREAACCHLAKALND\n"
183    + "FSNSGSDVLYQPPQTSITSAVLQSGFRKMAFPSGKVEGCMVQVTCGTTTLNGLWLDDVVYCPRHVICTSEDM\n"
184    + "LNPNYEDLLIRKSNHNFLVQAGNVQLRVIGHSMQNCVLKLKVDTANPKTPKYKFVRIQPGQTFSVLACYNGS\n"
185    + "PSGVYQCAMRPNFTIKGSFLNGSCGSVGFNIDYDCVSFCYMHHMELPTGVHAGTDLEGNFYGPFVDRQTAQA\n"
186    + "AGTDTTITVNVLAWLYAAVINGDRWFLNRFTTTLNDFNLVAMKYNYEPLTQDHVDILGPLSAQTGIAVLDMC\n"
187    + "ASLKELLQNGMNGRTILGSALLEDEFTPFDVVRQCSGVTFQSAVKRTIKGTHHWLLLTILTSLLVLVQSTQW\n"
188    + "SLFFFLYENAFLPFAMGIIAMSAFAMMFVKHKHAFLCLFLLPSLATVAYFNMVYMPASWVMRIMTWLDMVDT\n"
189    + "SLSGFKLKDCVMYASAVVLLILMTARTVYDDGARRVWTLMNVLTLVYKVYYGNALDQAISMWALIISVTSNY\n"
190    + "SGVVTTVMFLARGIVFMCVEYCPIFFITGNTLQCIMLVYCFLGYFCTCYFGLFCLLNRYFRLTLGVYDYLVS\n"
191    + "TQEFRYMNSQGLLPPKNSIDAFKLNIKLLGVGGKPCIKVATVQSKMSDVKCTSVVLLSVLQQLRVESSSKLW\n"
192    + "AQCVQLHNDILLAKDTTEAFEKMVSLLSVLLSMQGAVDINKLCEEMLDNRATLQAIASEFSSLPSYAAFATA\n"
193    + "QEAYEQAVANGDSEVVLKKLKKSLNVAKSEFDRDAAMQRKLEKMADQAMTQMYKQARSEDKRAKVTSAMQTM\n"
194    + "LFTMLRKLDNDALNNIINNARDGCVPLNIIPLTTAAKLMVVIPDYNTYKNTCDGTTFTYASALWEIQQVVDA\n"
195    + "DSKIVQLSEISMDNSPNLAWPLIVTALRANSAVKLQNNELSPVALRQMSCAAGTTQTACTDDNALAYYNTTK\n"
196    + "GGRFVLALLSDLQDLKWARFPKSDGTGTIYTELEPPCRFVTDTPKGPKVKYLYFIKGLNNLNRGMVLGSLAA\n"
197    + "TVRLQAGNATEVPANSTVLSFCAFAVDAAKAYKDYLASGGQPITNCVKMLCTHTGTGQAITVTPEANMDQES\n"
198    + "FGGASCCLYCRCHIDHPNPKGFCDLKGKYVQIPTTCANDPVGFTLKNTVCTVCGMWKGYGCSCDQLREPMLQ\n"
199    + "SADAQSFLNRVCGVSAARLTPCGTGTSTDVVYRAFDIYNDKVAGFAKFLKTNCCRFQEKDEDDNLIDSYFVV\n"
200    + "KRHTFSNYQHEETIYNLLKDCPAVAKHDFFKFRIDGDMVPHISRQRLTKYTMADLVYALRHFDEGNCDTLKE\n"
201    + "ILVTYNCCDDDYFNKKDWYDFVENPDILRVYANLGERVRQALLKTVQFCDAMRNAGIVGVLTLDNQDLNGNW\n"
202    + "YDFGDFIQTTPGSGVPVVDSYYSLLMPILTLTRALTAESHVDTDLTKPYIKWDLLKYDFTEERLKLFDRYFK\n"
203    + "YWDQTYHPNCVNCLDDRCILHCANFNVLFSTVFPPTSFGPLVRKIFVDGVPFVVSTGYHFRELGVVHNQDVN\n"
204    + "LHSSRLSFKELLVYAADPAMHAASGNLLLDKRTTCFSVAALTNNVAFQTVKPGNFNKDFYDFAVSKGFFKEG\n"
205    + "SSVELKHFFFAQDGNAAISDYDYYRYNLPTMCDIRQLLFVVEVVDKYFDCYDGGCINANQVIVNNLDKSAGF\n"
206    + "PFNKWGKARLYYDSMSYEDQDALFAYTKRNVIPTITQMNLKYAISAKNRARTVAGVSICSTMTNRQFHQKLL\n"
207    + "KSIAATRGATVVIGTSKFYGGWHNMLKTVYSDVENPHLMGWDYPKCDRAMPNMLRIMASLVLARKHTTCCSL\n"
208    + "SHRFYRLANECAQVLSEMVMCGGSLYVKPGGTSSGDATTAYANSVFNICQAVTANVNALLSTDGNKIADKYV\n"
209    + "RNLQHRLYECLYRNRDVDTDFVNEFYAYLRKHFSMMILSDDAVVCFNSTYASQGLVASIKNFKSVLYYQNNV\n"
210    + "FMSEAKCWTETDLTKGPHEFCSQHTMLVKQGDDYVYLPYPDPSRILGAGCFVDDIVKTDGTLMIERFVSLAI\n"
211    + "DAYPLTKHPNQEYADVFHLYLQYIRKLHDELTGHMLDMYSVMLTNDNTSRYWEPEFYEAMYTPHTVLQAVGA\n"
212    + "CVLCNSQTSLRCGACIRRPFLCCKCCYDHVISTSHKLVLSVNPYVCNAPGCDVTDVTQLYLGGMSYYCKSHK\n"
213    + "PPISFPLCANGQVFGLYKNTCVGSDNVTDFNAIATCDWTNAGDYILANTCTERLKLFAAETLKATEETFKLS\n"
214    + "YGIATVREVLSDRELHLSWEVGKPRPPLNRNYVFTGYRVTKNSKVQIGEYTFEKGDYGDAVVYRGTTTYKLN\n"
215    + "VGDYFVLTSHTVMPLSAPTLVPQEHYVRITGLYPTLNISDEFSSNVANYQKVGMQKYSTLQGPPGTGKSHFA\n"
216    + "IGLALYYPSARIVYTACSHAAVDALCEKALKYLPIDKCSRIIPARARVECFDKFKVNSTLEQYVFCTVNALP\n"
217    + "ETTADIVVFDEISMATNYDLSVVNARLRAKHYVYIGDPAQLPAPRTLLTKGTLEPEYFNSVCRLMKTIGPDM\n"
218    + "FLGTCRRCPAEIVDTVSALVYDNKLKAHKDKSAQCFKMFYKGVITHDVSSAINRPQIGVVREFLTRNPAWRK\n"
219    + "AVFISPYNSQNAVASKILGLPTQTVDSSQGSEYDYVIFTQTTETAHSCNVNRFNVAITRAKVGILCIMSDRD\n"
220    + "LYDKLQFTSLEIPRRNVATLQAENVTGLFKDCSKVITGLHPTQAPTHLSVDTKFKTEGLCVDIPGIPKDMTY\n"
221    + "RRLISMMGFKMNYQVNGYPNMFITREEAIRHVRAWIGFDVEGCHATREAVGTNLPLQLGFSTGVNLVAVPTG\n"
222    + "YVDTPNNTDFSRVSAKPPPGDQFKHLIPLMYKGLPWNVVRIKIVQMLSDTLKNLSDRVVFVLWAHGFELTSM\n"
223    + "KYFVKIGPERTCCLCDRRATCFSTASDTYACWHHSIGFDYVYNPFMIDVQQWGFTGNLQSNHDLYCQVHGNA\n"
224    + "HVASCDAIMTRCLAVHECFVKRVDWTIEYPIIGDELKINAACRKVQHMVVKAALLADKFPVLHDIGNPKAIK\n"
225    + "CVPQADVEWKFYDAQPCSDKAYKIEELFYSYATHSDKFTDGVCLFWNCNVDRYPANSIVCRFDTRVLSNLNL\n"
226    + "PGCDGGSLYVNKHAFHTPAFDKSAFVNLKQLPFFYYSDSPCESHGKQVVSDIDYVPLKSATCITRCNLGGAV\n"
227    + "CRHHANEYRLYLDAYNMMISAGFSLWVYKQFDTYNLWNTFTRLQSLENVAFNVVNKGHFDGQQGEVPVSIIN\n"
228    + "NTVYTKVDGVDVELFENKTTLPVNVAFELWAKRNIKPVPEVKILNNLGVDIAANTVIWDYKRDAPAHISTIG\n"
229    + "VCSMTDIAKKPTETICAPLTVFFDGRVDGQVDLFRNARNGVLITEGSVKGLQPSVGPKQASLNGVTLIGEAV\n"
230    + "KTQFNYYKKVDGVVQQLPETYFTQSRNLQEFKPRSQMEIDFLELAMDEFIERYKLEGYAFEHIVYGDFSHSQ\n"
231    + "LGGLHLLIGLAKRFKESPFELEDFIPMDSTVKNYFITDAQTGSSKCVCSVIDLLLDDFVEIIKSQDLSVVSK\n"
232    + "VVKVTIDYTEISFMLWCKDGHVETFYPKLQSSQAWQPGVAMPNLYKMQRMLLEKCDLQNYGDSATLPKGIMM\n"
233    + "NVAKYTQLCQYLNTLTLAVPYNMRVIHFGAGSDKGVAPGTAVLRQWLPTGTLLVDSDLNDFVSDADSTLIGD\n"
234    + "CATVHTANKWDLIISDMYDPKTKNVTKENDSKEGFFTYICGFIQQKLALGGSVAIKITEHSWNADLYKLMGH\n"
235    + "FAWWTAFVTNVNASSSEAFLIGCNYLGKPREQIDGYVMHANYIFWRNTNPIQLSSYSLFDMSKFPLKLRGTA\n"
236    + "VMSLKEGQINDMILSLLSKGRLIIRENNRVVISSDVLVNN");
237  9 upSeq_r1ab.setDescription("sars2 r1ab polyprotein");
238  9 upSeq_r1ab
239    .addDBRef(new DBRefEntry("UNIPROT", "0", "P0DTD1", null, true));
240  9 upSeq_r1ab.createDatasetSequence();
241  9 upSeq_fer1_maize = new Sequence("FER1_MAIZE",
242    "MATVLGSPRAPAFFFSSSSLRAAPAPTAVALPAAKVGIMGRSASSRRRLRAQATYNVKLITPEGE"
243    + "VELQVPDDVYILDQAEEDGIDLPYSCRAGSCSSCAGKVVSGSVDQSDQSYLDDGQIADGWVLTCHAYPTSDV"
244    + "VIETHKEEELTGA");
245  9 upSeq_fer1_maize.setDescription("Feredoxin 1 Maize");
246  9 upSeq_fer1_maize
247    .addDBRef(new DBRefEntry("UNIPROT", "0", "P27787", null, true));
248  9 upSeq_fer1_maize.createDatasetSequence();
249   
250  9 upSeq_epas1_human = new Sequence("EPAS1_HUMAN",
251    "MTADKEKKRSSSERRKEKSRDAARCRRSKETEVFYELAHELPLPHSVSSHLDKASIMRLAISFLRTHKLLSS\n"
252    + "VCSENESEAEADQQMDNLYLKALEGFIAVVTQDGDMIFLSENISKFMGLTQVELTGHSIFDFTHPCDHEEIR\n"
253    + "ENLSLKNGSGFGKKSKDMSTERDFFMRMKCTVTNRGRTVNLKSATWKVLHCTGQVKVYNNCPPHNSLCGYKE\n"
254    + "PLLSCLIIMCEPIQHPSHMDIPLDSKTFLSRHSMDMKFTYCDDRITELIGYHPEELLGRSAYEFYHALDSEN\n"
255    + "MTKSHQNLCTKGQVVSGQYRMLAKHGGYVWLETQGTVIYNPRNLQPQCIMCVNYVLSEIEKNDVVFSMDQTE\n"
256    + "SLFKPHLMAMNSIFDSSGKGAVSEKSNFLFTKLKEEPEELAQLAPTPGDAIISLDFGNQNFEESSAYGKAIL\n"
257    + "PPSQPWATELRSHSTQSEAGSLPAFTVPQAAAPGSTTPSATSSSSSCSTPNSPEDYYTSLDNDLKIEVIEKL\n"
258    + "FAMDTEAKDQCSTQTDFNELDLETLAPYIPMDGEDFQLSPICPEERLLAENPQSTPQHCFSAMTNIFQPLAP\n"
259    + "VAPHSPFLLDKFQQQLESKKTEPEHRPMSSIFFDAGSKASLPPCCGQASTPLSSMGGRSNTQWPPDPPLHFG\n"
260    + "PTKWAVGDQRTEFLGAAPLGPPVSPPHVSTFKTRSAKGFGARGPDVLSPAMVALSNKLKLKRQLEYEEQAFQ\n"
261    + "DLSGGDPPGGSTSHLMWKRMKNLRGGSCPLMPDKPLSANVPNDKFTQNPMRGLGHPLRHLPLPQPPSAISPG\n"
262    + "ENSKSRFPPQCYATQYQDYSLSSAHKVSGMASRLLGPSFESYLLPELTRYDCEVNVPVLGSSTLLQGGDLLR\n"
263    + "ALDQAT");
264  9 upSeq_epas1_human
265    .setDescription("Endothelial PAS domain-containing protein 1");
266  9 upSeq_epas1_human
267    .addDBRef(new DBRefEntry("UNIPROT", "0", "Q99814", null, true));
268  9 upSeq_epas1_human.createDatasetSequence();
269    }
270   
 
271  8 toggle @AfterMethod(alwaysRun = true)
272    public void tearDown() throws Exception
273    {
274  8 seq = null;
275  8 upSeq = null;
276  8 upSeq_r1ab = null;
277  8 upSeq_fer1_maize = null;
278  8 upSeq_epas1_human = null;
279    }
280   
 
281  1 toggle @SuppressWarnings("deprecation")
282    @Test(groups = { "Functional" })
283    public void buildPDBQueryTest()
284    {
285  1 System.out.println("seq >>>> " + seq);
286   
287  1 StructureChooserQuerySource scquery = StructureChooserQuerySource
288    .getQuerySourceFor(new SequenceI[]
289    { seq });
290  1 AssertJUnit
291    .assertTrue(scquery instanceof PDBStructureChooserQuerySource);
292  1 String query = scquery.buildQuery(seq);
293  1 AssertJUnit.assertEquals("pdb_id:1tim", query);
294  1 seq.getAllPDBEntries().clear();
295  1 query = scquery.buildQuery(seq);
296  1 AssertJUnit.assertEquals(
297    "text:XYZ_1 OR text:XYZ_2 OR text:XYZ_3 OR text:XYZ_4 OR text:4kqy",
298    query);
299  1 seq.setDBRefs(null);
300  1 query = scquery.buildQuery(seq);
301  1 System.out.println(query);
302  1 AssertJUnit.assertEquals("text:4kqy", query);
303   
304  1 DBRefEntry uniprotDBRef = new DBRefEntry();
305  1 uniprotDBRef.setAccessionId("P12345");
306  1 uniprotDBRef.setSource(DBRefSource.UNIPROT);
307  1 seq.addDBRef(uniprotDBRef);
308   
309  1 DBRefEntry pdbDBRef = new DBRefEntry();
310  1 pdbDBRef.setAccessionId("1XYZ");
311  1 pdbDBRef.setSource(DBRefSource.PDB);
312  1 seq.addDBRef(pdbDBRef);
313   
314  5 for (int x = 1; x < 5; x++)
315    {
316  4 DBRefEntry dbRef = new DBRefEntry();
317  4 dbRef.setAccessionId("XYZ_" + x);
318  4 seq.addDBRef(dbRef);
319    }
320  1 System.out.println("");
321  1 System.out.println(seq.getDBRefs());
322  1 System.out.println(query);
323  1 query = scquery.buildQuery(seq);
324  1 AssertJUnit.assertEquals(
325    "uniprot_accession:P12345 OR uniprot_id:P12345 OR pdb_id:1xyz",
326    query);
327    }
328   
 
329  1 toggle @SuppressWarnings("deprecation")
330    @Test(groups = { "Functional" })
331    public void buildThreeDBQueryTest()
332    {
333  1 System.out.println("seq >>>> " + upSeq);
334  1 TDBeaconsFTSRestClientTest.setMock();
335  1 PDBFTSRestClientTest.setMock();
336  1 StructureChooserQuerySource scquery = StructureChooserQuerySource
337    .getQuerySourceFor(new SequenceI[]
338    { upSeq });
339    // gets the lightweight proxy rather than the
340    // ThreeDBStructureChooserQuerySource
341  1 AssertJUnit.assertTrue(
342    scquery instanceof ThreeDBStructureChooserQuerySource);
343  1 String query = scquery.buildQuery(upSeq);
344  1 AssertJUnit.assertEquals("P38398", query);
345   
346    // query shouldn't change regardless of additional entries
347    // because 3DBeacons requires canonical entries.
348  1 upSeq.getAllPDBEntries().clear();
349  1 query = scquery.buildQuery(upSeq);
350  1 AssertJUnit.assertEquals("P38398", query);
351  1 upSeq.setDBRefs(null);
352  1 query = scquery.buildQuery(upSeq);
353    /*
354    * legacy projects/datasets will not have canonical flags set for uniprot dbrefs
355    * graceful behaviour would be to
356    * - pick one ? not possible
357    * - iterate through all until a 200 is obtained ?
358    * ---> ideal but could be costly
359    * ---> better to do a direct retrieval from uniprot to work out which is the canonical identifier..
360    * ----> need a test to check that accessions can be promoted to canonical!
361    */
362    // FIXME - need to be able to use ID to query here ?
363  1 AssertJUnit.assertEquals(null, query);
364   
365    // TODO:
366    /**
367    * set of sequences: - no protein -> TDB not applicable, query PDBe only
368    * (consider RNA or DNA - specific query adapter ?) - protein but no uniprot
369    * -> first consider trying to get uniprot refs (need a mark to say none are
370    * available) - protein and uniprot - no canonicals -> resolve to uniprot
371    * automatically to get canonicals - query uniprot against 3DBeacons -->
372    * decorate experimental structures with additional data from PDBe - query
373    * remaining against PDBe Ranking - 3D Beacons --> in memory ranking - no
374    * need to query twice Rank by - experimental > AlphaFold -> Model - start >
375    * end -> filters for -> experimental only -> experimental plus best models
376    * for other regions -> "best cover" -> need to be able to select correct
377    * reference (the longest one that covers all) for superposition
378    */
379    //
380    // DBRefEntry uniprotDBRef = new DBRefEntry();
381    // uniprotDBRef.setAccessionId("P12345");
382    // uniprotDBRef.setSource(DBRefSource.UNIPROT);
383    // upSeq.addDBRef(uniprotDBRef);
384    //
385    // DBRefEntry pdbDBRef = new DBRefEntry();
386    // pdbDBRef.setAccessionId("1XYZ");
387    // pdbDBRef.setSource(DBRefSource.PDB);
388    // upSeq.addDBRef(pdbDBRef);
389    //
390    // for (int x = 1; x < 5; x++)
391    // {
392    // DBRefEntry dbRef = new DBRefEntry();
393    // dbRef.setAccessionId("XYZ_" + x);
394    // seq.addDBRef(dbRef);
395    // }
396    // System.out.println("");
397    // System.out.println(seq.getDBRefs());
398    // System.out.println(query);
399    // query = scquery.buildQuery(seq);
400    // assertEquals(
401    // "uniprot_accession:P12345 OR uniprot_id:P12345 OR pdb_id:1xyz",
402    // query);
403    }
404   
 
405  5 toggle @Test(groups = { "Functional" }, dataProvider = "testUpSeqs")
406    public void cascadingThreeDBandPDBQuerys(SequenceI testUpSeq)
407    {
408  5 TDBeaconsFTSRestClientTest.setMock();
409  5 PDBFTSRestClientTest.setMock();
410  5 ThreeDBStructureChooserQuerySource tdbquery = new ThreeDBStructureChooserQuerySource();
411  5 PDBStructureChooserQuerySource pdbquery = new PDBStructureChooserQuerySource();
412   
413  5 FTSRestResponse upResponse = null;
414  5 List<FTSRestResponse> pdbResponse = null;
415    // TODO test available options
416    // Best coverage
417    // Best Alphafold Model
418    // Best model (by confidence score)
419    // Will also need to develop a more sophisticated filtering system
420  5 List<FilterOption> opts = tdbquery
421    .getAvailableFilterOptions(StructureChooser.VIEWS_FILTER);
422  5 FilterOption opt_singlebest = opts.get(0);
423  5 FilterOption opt_manybest = opts.get(1);
424  5 assertEquals(opt_singlebest.getValue(),
425    ThreeDBStructureChooserQuerySource.FILTER_FIRST_BEST_COVERAGE);
426  5 assertEquals(opt_manybest.getValue(),
427    ThreeDBStructureChooserQuerySource.FILTER_TDBEACONS_COVERAGE);
428   
429  5 try
430    {
431  5 upResponse = tdbquery.fetchStructuresMetaData(testUpSeq,
432    tdbquery.getDocFieldPrefs().getStructureSummaryFields(),
433    opt_singlebest, false);
434  5 tdbquery.updateAvailableFilterOptions(StructureChooser.VIEWS_FILTER,
435    opts, upResponse.getSearchSummary());
436    // test ranking without additional PDBe data
437  5 FTSRestResponse firstRanked = tdbquery.selectFirstRankedQuery(
438    testUpSeq, upResponse.getSearchSummary(),
439    tdbquery.getDocFieldPrefs().getStructureSummaryFields(),
440    opt_singlebest.getValue(), false);
441  5 assertEquals(firstRanked.getNumberOfItemsFound(), 1);
442    // many best response
443  5 upResponse = tdbquery.fetchStructuresMetaData(testUpSeq,
444    tdbquery.getDocFieldPrefs().getStructureSummaryFields(),
445    opt_manybest, false);
446  5 assertTrue(firstRanked.getSearchSummary().size() < upResponse
447    .getSearchSummary().size());
448    // NB Could have race condition here
449  5 List<String> pdb_Queries = tdbquery.buildPDBFTSQueryFor(upResponse);
450  5 assertTrue(pdb_Queries.size() > 0);
451  5 for (String pdb_Query : pdb_Queries)
452    {
453  10 assertTrue(pdb_Query.trim().length() > 0);
454    }
455   
456  5 pdbResponse = tdbquery.fetchStructuresMetaDataFor(pdbquery,
457    upResponse);
458    // check all queries resulted in a response
459  5 assertEquals(pdbResponse.size(), pdb_Queries.size());
460  5 for (FTSRestResponse pdbr : pdbResponse)
461    {
462  10 assertTrue(pdbr.getNumberOfItemsFound() > 0);
463    }
464   
465    // and finally that join works
466  5 FTSRestResponse joinedResp = tdbquery.joinResponses(upResponse,
467    pdbResponse);
468  5 assertEquals(upResponse.getNumberOfItemsFound(),
469    joinedResp.getNumberOfItemsFound());
470   
471    // Special data test case
472  5 if (testUpSeq.getDisplayId(true)
473    .equals(upSeq_epas1_human.getDisplayId(true)))
474    {
475   
476  1 TDBResultAnalyser tDBResultAnalyz = new TDBResultAnalyser(testUpSeq,
477    joinedResp.getSearchSummary(), tdbquery.lastTdbRequest,
478    ThreeDBStructureChooserQuerySource.FILTER_FIRST_BEST_COVERAGE,
479    tdbquery.remove_prefix(
480    ThreeDBStructureChooserQuerySource.FILTER_FIRST_BEST_COVERAGE));
481  1 List<FTSData> ordered = tDBResultAnalyz.getFilteredResponse();
482  1 List<FTSData> selected = tDBResultAnalyz.selectStructures(ordered);
483  1 assertEquals(((TDB_FTSData) selected.get(0)).getProvider(),
484    "AlphaFold DB");
485    // to be sufficient, should also
486    // test that adjacent ordered structure in ordered is levyLab
487    // TDB_FTSData first = (TDB_FTSData) ordered.get(0),
488    // second = (TDB_FTSData) ordered.get(1),
489    // third = (TDB_FTSData) ordered.get(2);
490    // Assert.assertEquals("pLDDT", first.getConfidenceScoreType());
491    // Assert.assertTrue(first.getConfidenceScoreType()
492    // .equals(second.getConfidenceScoreType())); // pLDDT first and
493    // // second
494    }
495   
496    } catch (
497   
498    Exception x)
499    {
500  0 x.printStackTrace();
501  0 Assert.fail("Unexpected Exception");
502    }
503   
504  5 StructureChooserQuerySource scquery = StructureChooserQuerySource
505    .getQuerySourceFor(new SequenceI[]
506    { testUpSeq });
507   
508    }
509   
 
510  1 toggle @DataProvider(name = "testUpSeqs")
511    public Object[][] testUpSeqs() throws Exception
512    {
513  1 setUp();
514  1 return new Object[][] { { upSeq }, { upSeq_insulin }, { upSeq_r1ab },
515    { upSeq_fer1_maize },
516    { upSeq_epas1_human } };
517    }
518   
 
519  1 toggle @Test(groups = { "Functional" })
520    public void sanitizeSeqNameTest()
521    {
522  1 String name = "ab_cdEF|fwxyz012349";
523  1 AssertJUnit.assertEquals(name,
524    PDBStructureChooserQuerySource.sanitizeSeqName(name));
525   
526    // remove a [nn] substring
527  1 name = "abcde12[345]fg";
528  1 AssertJUnit.assertEquals("abcde12fg",
529    PDBStructureChooserQuerySource.sanitizeSeqName(name));
530   
531    // remove characters other than a-zA-Z0-9 | or _
532  1 name = "ab[cd],.\t£$*!- \\\"@:e";
533  1 AssertJUnit.assertEquals("abcde",
534    PDBStructureChooserQuerySource.sanitizeSeqName(name));
535   
536  1 name = "abcde12[345a]fg";
537  1 AssertJUnit.assertEquals("abcde12345afg",
538    PDBStructureChooserQuerySource.sanitizeSeqName(name));
539    }
540    }