Exemple #1
0
        protected void InitMeasure(string dirName,string alignFile,bool flag,PDBMODE allAtoms,string refJuryProfile=null)
        {
            base.InitMeasure(dirName, alignFile, flag, refJuryProfile);            
            pdbs = new PDBFiles();
            string[] files;
            if(dirSettings.extension==null)
                files = Directory.GetFiles(dirName);
            else
                files = Directory.GetFiles(dirName, dirSettings.extension);

            if (files.Length == 0)
                throw new Exception("In selected directory " + dirName + " there are no files with extesion " + dirSettings.extension);

            maxV = files.Length;

            string refSeqFile = dirName + ".ref";
            pdbs.ReadRefSeq(refSeqFile);

            currentV = 0;
            pdbs.AddPDB(files, allAtoms,ref currentV);

            if (pdbs.molDic.Keys.Count == 0)
                throw new Exception("Non pdb files correctly read");
            pdbs.FindReferenceSeq();
            pdbs.MakeAlignment(alignFile);
            structNames = CheckAvailableStructures();
            order = true;
            atomDic = pdbs.MakeAllAtomsDic();
         }
        public override int Run(object processParams)
        {
            Dictionary<int, List<int>> contacts= new Dictionary<int, List<int>>();
            string fileName = ((ThreadFiles)(processParams)).fileName;

            List<string> files = threadingList[((ThreadFiles)(processParams)).threadNumber];// CheckFile(listFile);
            if (files.Count == 0)
                return 0;
            StreamWriter wr;
                                 
            if (File.Exists(fileName))
                wr = File.AppendText(fileName);
            else
                wr = new StreamWriter(fileName);

            if (wr == null)
                throw new Exception("Cannot open file: " + fileName);

            PDBFiles pdbs = new PDBFiles();

            string refSeqFile = ((ThreadFiles)(processParams)) + ".ref";
            pdbs.ReadRefSeq(refSeqFile);
            maxV = files.Count;
            try
            {
                foreach (var item in files)
                {
                    string strName;
                    //strName = pdbs.AddPDB(item, PDBMODE.CA_CB);
                    if (this.GetType() == typeof(ContactProfile))
                        strName = pdbs.AddPDB(item, PDBMODE.ALL_ATOMS);
                    else
                        strName = pdbs.AddPDB(item, PDBMODE.ONLY_CA);
                    if(strName!=null)
                        MakeProfiles(strName,pdbs.molDic[strName], wr);

                    currentProgress++;
                }
            }
            catch (Exception ex)
            {
               // wr.Close();
                throw new Exception(ex.Message);
            }

            wr.Close();
            currentProgress = maxV;
            return 0;
        }