示例#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();
        }
示例#2
0
        public Rmsd(string dirName, string alignFile, bool flag, PDBMODE allAtoms, string refJuryProfile = null) : base(dirName, alignFile, flag, refJuryProfile)
        {
            dirSettings.Load();
            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);
            }

            string refSeqFile = dirName + ".ref";

            pdbs.ReadRefSeq(refSeqFile);


            pdbs.AddPDB(files, allAtoms);

            if (pdbs.molDic.Keys.Count == 0)
            {
                throw new Exception("Non pdb files correctly read");
            }
            pdbs.FindReferenceSeq();
            pdbs.MakeAlignment(alignFile);
            opt         = new Optimization();
            structNames = CheckAvailableStructures();
            order       = true;
        }
示例#3
0
        public Rmsd(string dirName,string alignFile,bool flag,PDBMODE allAtoms,string refJuryProfile=null):base(dirName,alignFile,flag,refJuryProfile)
        {

            dirSettings.Load();
            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);

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


            pdbs.AddPDB(files, allAtoms);

            if (pdbs.molDic.Keys.Count == 0)
                throw new Exception("Non pdb files correctly read");
            pdbs.FindReferenceSeq();
            pdbs.MakeAlignment(alignFile);
			opt=new Optimization();
            structNames = CheckAvailableStructures();
            order = true;
         }
示例#4
0
        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 (dirSettings.mode == INPUTMODE.PROTEIN)
                    {
                        if (this.GetType() == typeof(ContactProfile))
                        {
                            strName = pdbs.AddPDB(item, PDBMODE.ALL_ATOMS);
                        }
                        else
                        {
                            strName = pdbs.AddPDB(item, PDBMODE.ONLY_CA);
                        }
                    }
                    else
                    {
                        strName = pdbs.AddPDB(item, PDBMODE.ONLY_P_AND_C4);
                    }
                    if (strName != null)
                    {
                        MakeProfiles(strName, pdbs.molDic[strName], wr);
                    }

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

            wr.Close();
            currentProgress = maxV;
            return(0);
        }
示例#5
0
        public override void RunThreads(string fileName)
        {
            List <string> files = CheckFile(fileName);

            if (files.Count == 0)
            {
                return;
            }

            //Task[] runnigTask = new Task[threadNumbers];
            //Task startProg;
            maxV = files.Count * 2;
            ReadPdbs(files);
            if (pdbs.molDic.Count == 0)
            {
                return;
            }
            string aux = Path.GetDirectoryName(files[0]).TrimEnd(Path.DirectorySeparatorChar);

            string refSeqFile = aux + ".ref";

            if (File.Exists(refSeqFile))
            {
                pdbs.ReadRefSeq(refSeqFile);
            }
            else
            {
                pdbs.FindReferenceSeq();
            }
            pdbs.MakeAlignment(null);

            if (contOne == null)
            {
                string molDicKey = "";
                foreach (var item in pdbs.molDic.Keys)
                {
                    molDicKey = item;
                    break;
                }
                int len = pdbs.molDic[molDicKey].indexMol.Length;
                contOne         = new int[len * (len + 1) / 2];
                contact         = new byte[threadNumbers][];
                contactToString = new char [threadNumbers][];

                for (int i = 0; i < threadNumbers; i++)
                {
                    contact[i]         = new byte [len * (len + 1) / 2];
                    contactToString[i] = new char [len * (len + 1)];
                }

                for (int i = 0; i < contOne.Length; i++)
                {
                    contOne[i] = 0;
                }
                for (int i = 0; i < threadNumbers; i++)
                {
                    for (int j = 0; j < contOne.Length; j++)
                    {
                        contact[i][j] = 0;
                    }
                }
            }

            auxFiles = new List <string> [threadNumbers];
            List <string> allFiles = new List <string>(pdbs.molDic.Keys);



            for (int i = 0; i < threadNumbers; i++)
            {
                auxFiles[i] = new List <string>((i + 1) * pdbs.molDic.Count / threadNumbers - i * pdbs.molDic.Count / threadNumbers);
                for (int j = i * allFiles.Count / threadNumbers; j < (i + 1) * allFiles.Count / threadNumbers; j++)
                {
                    auxFiles[i].Add(files[j]);
                }
            }
            for (int i = 0; i < threadNumbers; i++)
            {
                Params p = new Params();
                p.fileName = fileName;
                p.k        = i;

                resetEvents[p.k] = new ManualResetEvent(false);
                ThreadPool.QueueUserWorkItem(new WaitCallback(RunMakeProfiles), (object)p);
            }
            for (int i = 0; i < threadNumbers; i++)
            {
                resetEvents[i].WaitOne();
            }

            //JoinFiles(fileName);

            CuttProfiles(fileName);
            currentProgress = maxV;
        }