1/** 2 * Session class. 3 */ 4const Session = new class { 5 constructor() { 6 // Dictionary of imported plasmid files 7 this.plasmids = {}; 8 9 // Currently active plasmid file 10 this.activePlasmidIndex = null; 11 12 // Index of plasmid from where the subcloning originates 13 this.subcloningOriginPlasmidIndex = null; 14 // Span of subcloning target in origin plasmid 15 this.subcloningOriginSpan = null; 16 }; 17 18 19 /** 20 * Get the next available index for a new plasmid. 21 * 22 * @returns - Index. 23 */ 24 nextFreeIndex() { 25 const entriesList = Object.keys(this.plasmids); 26 27 // There are no plasmids yet, return 0 28 if (entriesList.length == 0) { 29 return 0; 30 } 31 32 // Get the last plasmid in the list and return its index + 1 33 return parseInt(entriesList[entriesList.length - 1]) + 1; 34 }; 35 36 37 /** 38 * Add a new plasmid to the session. 39 * 40 * @param {Object} newPlasmid - Plasmid to be added. 41 */ 42 addPlasmid(newPlasmid) { 43 // Check if index was given 44 const currIndex = newPlasmid.index; 45 // Add plasmid object to session 46 this.plasmids[currIndex] = newPlasmid; 47 48 // Create a new tab 49 PlasmidTabs.new(currIndex, newPlasmid.name + newPlasmid.extension); 50 }; 51 52 53 /** 54 * Return active plasmid object 55 * 56 * @returns {Plasmid} - Active plasmid 57 */ 58 activePlasmid() { 59 return this.plasmids[this.activePlasmidIndex]; 60 }; 61 62 63 /** 64 * Returns plasmid by index. 65 * 66 * @param {int} index - Index of plasmid to be retrieved. 67 * @returns - Plasmid matching specified index. 68 */ 69 getPlasmid(index) { 70 return this.plasmids[index]; 71 }; 72 73 74 markForSubcloning(span=null) { 75 if (span === null) span = Session.activePlasmid().getSelectionIndices(); 76 this.subcloningOriginPlasmidIndex = Session.activePlasmidIndex; 77 this.subcloningOriginSpan = span; 78 79 if (this.subcloningOriginSpan[1] - this.subcloningOriginSpan[0] < 400) { 80 Alerts.warning( 81 "Short subcloning target", 82 "Attempting to subclone fragments shorter than 400 bp may result in lower efficiency or the subcloning may fail all together.", 83 10 84 ); 85 }; 86 87 PlasmidViewer.highlightSubcloningTarget(); 88 }; 89 90 91 removeMarkForSubcloning() { 92 this.subcloningOriginPlasmidIndex = null; 93 this.subcloningOriginSpan = null; 94 95 PlasmidViewer.highlightSubcloningTarget(); 96 }; 97 98 99 isSubcloningRegionMarked() { 100 return this.subcloningOriginPlasmidIndex != null && this.subcloningOriginSpan != null; 101 }; 102};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.