<commit_before>/* Gets ZINC IDs from file; adds to array zincIds
 * @author <NAME> & csera
 * @param {FileReader.result} Parsed file contents to scan
 */
function parseForZinc(fileText, objId){
   //Note: THIS WILL NOT WORK WITH FILES CONTAINING MULTIPLE ZINC IDs
   var regex = /ZINC/i; //Matches to first case-insensitive (i) instance of "ZINC"
   var zincLoc = fileText.search(regex);
   
   //12 is length of ZINC ID
   var zId = fileText.slice(zincLoc, zincLoc+12);
   
   //Set the ZINC ID as a new property for the object
   dataObjs.getItem(objId).zincId = zId;
   
   /*fileText = readerResult;
   //Get rid of duplicate adding bug by only processing from @<TRIPOS>MOLECULE to @<TRIPOS>ATOM
   //if it is a .mol2
   var regex = /ZINC/gi; //All (g, global) case-insensitive (i) matches for "ZINC"
   var result, indices = [];
   var zincIds = [],
   bonds = [],
   numRes = [];
   while ( (result = regex.exec(fileText)) )
   {
       indices.push(result.index);
       // 12 is the length of ZINC id
       zincs = fileText.slice(result.index, result.index + 12);
       zincIds.push(zincs);
   }
   //lines = fileText.split("\n");
   console.log("indices: "+indices);*/
   
   /*for(var x=0; x<indices.length;x++)
   {
      infoLine = lines.slice(indices[x] + 3, indices[x] + 4);
      console.log("infoLine: "+infoLine);
      stringLine = infoLine.toString();
      a1 = stringLine.search("\ ")+1;
      a2 = stringLine.slice(a1, stringLine.length).search("\ ")+1;
      atomInfo = stringLine.slice(a1, a2);
      bondString = stringLine.slice(a2+1, stringLine.length);
      b1 = bondString.search("\ ");
      bondInfo = bondString.slice(0,b1);
      bonds.push(bondInfo);
      numRes.push(atomInfo);
   }*/
   //compound_fxn(zincIds, nAtmArr, nBndArr); 17 Sept '15 commented out
   // compListDetails(zincIds, numRes, bonds);
   //console.log(numRes, bonds);
}

/* Searches file text for information from a .mol2 file and adds it to
 * the relevant object placed in the main interface. Info can be read
 * natively from a .mol2 or from an object created by the file processor.
 * @param {String} fileText Plain text of the processed file
 */
function parseLigInfo(fileText){
   var ligInfo = new Object();
   
   var zincRmkLoc = fileText.search("REMARK   11\nREMARK   11 ZINC")
      //fileText.search(/REMARK   11 ZINC/i);
   var endInfoLoc = fileText.search("REMARK   20 END LIGAND INFO");
   
   //For custom format from file processor   
   /* Format used by file processor:
    *    REMARK   11
    *    REMARK   11 ZINC_ID
    *    REMARK   12
    *    REMARK   12 num_atoms [num_bonds] [num_subst] [num_feat] [num_sets]
    *    [REMARK   15
    *    REMARK   15 COMPOUND_NAME]
    *    REMARK   20
    *    REMARK   20 END LIGAND INFO
    */
   if (zincRmkLoc!=-1 && endInfoLoc!=-1) {
      //27 is length of the final line of the end block
      //Split this identified block into an array by lines
      var infoLines = fileText.substr(zincRmkLoc,endInfoLoc+27).split(/\r?\n/);<commit_msg>Minor: most String.search() -> String.indexOf()<commit_after>/* Gets ZINC IDs from file; adds to array zincIds
 * @author <NAME> & csera
 * @param {FileReader.result} Parsed file contents to scan
 */
function parseForZinc(fileText, objId){
   //Note: THIS WILL NOT WORK WITH FILES CONTAINING MULTIPLE ZINC IDs
   var regex = /ZINC/i; //Matches to first case-insensitive (i) instance of "ZINC"
   var zincLoc = fileText.search(regex);
   
   //12 is length of ZINC ID
   var zId = fileText.slice(zincLoc, zincLoc+12);
   
   //Set the ZINC ID as a new property for the object
   dataObjs.getItem(objId).zincId = zId;
   
   /*fileText = readerResult;
   //Get rid of duplicate adding bug by only processing from @<TRIPOS>MOLECULE to @<TRIPOS>ATOM
   //if it is a .mol2
   var regex = /ZINC/gi; //All (g, global) case-insensitive (i) matches for "ZINC"
   var result, indices = [];
   var zincIds = [],
   bonds = [],
   numRes = [];
   while ( (result = regex.exec(fileText)) )
   {
       indices.push(result.index);
       // 12 is the length of ZINC id
       zincs = fileText.slice(result.index, result.index + 12);
       zincIds.push(zincs);
   }
   //lines = fileText.split("\n");
   console.log("indices: "+indices);*/
   
   /*for(var x=0; x<indices.length;x++)
   {
      infoLine = lines.slice(indices[x] + 3, indices[x] + 4);
      console.log("infoLine: "+infoLine);
      stringLine = infoLine.toString();
      a1 = stringLine.search("\ ")+1;
      a2 = stringLine.slice(a1, stringLine.length).search("\ ")+1;
      atomInfo = stringLine.slice(a1, a2);
      bondString = stringLine.slice(a2+1, stringLine.length);
      b1 = bondString.search("\ ");
      bondInfo = bondString.slice(0,b1);
      bonds.push(bondInfo);
      numRes.push(atomInfo);
   }*/
   //compound_fxn(zincIds, nAtmArr, nBndArr); 17 Sept '15 commented out
   // compListDetails(zincIds, numRes, bonds);
   //console.log(numRes, bonds);
}

/* Searches file text for information from a .mol2 file and adds it to
 * the relevant object placed in the main interface. Info can be read
 * natively from a .mol2 or from an object created by the file processor.
 * @param {String} fileText Plain text of the processed file
 */
function parseLigInfo(fileText){
   var ligInfo = new Object();
   
   //use String.indexOf() for string args bc faster
   //String.search() converts to regex -> slower
   var zincRmkLoc = fileText.indexOf("REMARK   11\nREMARK   11 ZINC")
      //fileText.search(/REMARK   11 ZINC/i);
   var endInfoLoc = fileText.indexOf("REMARK   20 END LIGAND INFO");
   
   //For custom format from file processor   
   /* Format used by file processor:
    *    REMARK   11
    *    REMARK   11 ZINC_ID
    *    REMARK   12
    *    REMARK   12 num_atoms [num_bonds] [num_subst] [num_feat] [num_sets]
    *    [REMARK   15
    *    REMARK   15 COMPOUND_NAME]
    *    REMARK   20
    *    REMARK   20 END LIGAND INFO
    */
   if (zincRmkLoc!=-1 && endInfoLoc!=-1) {
      //27 is length of the final line of the end block
      //Split this identified block into an array by lines
      var infoLines = fileText.substr(zincRmkLoc,endInfoLoc+27).split(/\r?\n/);
{'fraction_non_alphanumeric': 0.12461513531032248, 'fraction_numerical': 0.019445794846864366, 'mean_word_length': 2.772616136919315, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6562727', 'n_tokens_mistral': 2183, 'n_tokens_neox': 2079, 'n_words': 624}