Example #1
0
        public Rmsd(DCDFile dcd, string alignFile, bool flag, PDBMODE allAtoms, string refJuryProfile = null)
            : base(dcd, alignFile, flag, refJuryProfile)
        {
            DCDReader readDCD = new DCDReader(dcd);

            dirSettings.Load();

            pdbs = new PDBFiles();
            readDCD.DCDPrepareReading(dcd.dcdFile, dcd.pdbFile);
            int  counter = 0;
            bool cont    = true;

            do
            {
                MemoryStream mStream = new MemoryStream();
                StreamWriter wStream = new StreamWriter(mStream);
                cont = readDCD.ReadAndSavePDB(wStream);
                string name = "Model" + counter++;
                mStream.Position = 0;
                pdbs.AddPDB(mStream, allAtoms, name);
            }while(cont);

            readDCD.FinishDCDReading();

            pdbs.FindReferenceSeq();
            pdbs.MakeAlignment(alignFile);
            if (pdbs is ErrorBase)
            {
                AddErrors(pdbs.errors);
            }
            opt = new Optimization();

            structNames = CheckAvailableStructures();
            order       = true;
        }
Example #2
0
        public Rmsd(DCDFile dcd, string alignFile, bool flag, PDBMODE allAtoms, string refJuryProfile = null)
            : base(dcd, alignFile, flag, refJuryProfile)
        {
            DCDReader readDCD = new DCDReader(dcd);
                dirSettings.Load();
            
            pdbs = new PDBFiles();
            readDCD.DCDPrepareReading(dcd.dcdFile, dcd.pdbFile);
            int counter = 0;
            bool cont = true;
            do
            {
                MemoryStream mStream = new MemoryStream();
                StreamWriter wStream = new StreamWriter(mStream);
                cont=readDCD.ReadAndSavePDB(wStream);
                string name = "Model" + counter++;
                mStream.Position = 0;
                pdbs.AddPDB(mStream, allAtoms, name);
            }
            while(cont);

            readDCD.FinishDCDReading();

            pdbs.FindReferenceSeq();
            pdbs.MakeAlignment(alignFile);
            if(pdbs is ErrorBase)
                AddErrors(pdbs.errors);
            opt = new Optimization();

            structNames = CheckAvailableStructures();
            order = true;
        }
Example #3
0
        void PrepareSift()
        {
            pdbs = new PDBFiles();
            maxV = listFiles.Count * 2 + 1;
            foreach (var item in listFiles)
            {
                string[] aux = item.Split('\\');
                //  if (!fileList.ContainsKey(aux[aux.Length-1]))
                //       continue;

                string strName;
                strName = pdbs.AddPDB(item, PDBMODE.ALL_ATOMS);
                if (strName != null)
                {
                    pdbs.molDic[strName].CreateSideChainContactMap(11.0f, true);
                    pdbs.molDic[strName].CleanMolData();
                }
                currentV++;
            }
            step = (double)(stop - start) / binNumber;

            for (double i = start; i < stop; i += step)
            {
                binLen.Add(i + step);
            }
        }
Example #4
0
        protected void MakeProfiles(string strName, MolData molDic, StreamWriter wr, int k)
        {
            if (molDic != null)
            {
                PDBFiles pdb = new PDBFiles();
                pdb.AddPDB(strName, PDBMODE.ONLY_CA);
                DebugClass.WriteMessage("Make Started");
                //int []contact=pdbs.molDic[strName].CreateFullContactMap(8.5f);
                //molDic.CreateFullContactMap(9.5f,contact[k]);//correct
                List <string> cc = new List <string>(pdb.molDic.Keys);
                pdb.molDic[cc[0]].indexMol = molDic.indexMol;
                GenerateContactMap(pdb.molDic[cc[0]], k);
                //pdb.molDic[cc[0]].CreateFullContactMap(8.5f, contact[k]);
                //molDic.CreateFullContactMap(8.5f,contact[k]);
                //pdbs.molDic[strName].CreateContactMap(9.5f, "CB");


                for (int i = 0; i < contact[k].Length; i++)
                {
                    if (contact[k][i] == 1)
                    {
                        contOne[i]++;
                    }
                }
                int j = 0;
                for (int i = 0; i < contact[k].Length - 1; i++)
                {
                    if (contact[k][i] == 1)
                    {
                        contactToString[k][j++] = '1';
                    }
                    else
                    {
                        contactToString[k][j++] = '0';
                    }

                    contactToString[k][j++] = ' ';
                }
                if (contact[k][contact[k].Length - 1] == 1)
                {
                    contactToString[k][j] = '1';
                }
                else
                {
                    contactToString[k][j] = '0';
                }

                string all = new string(contactToString[k], 0, j);

                wr.WriteLine(">" + cc[0]);
                //for (int i = 0; i < contact[k].Length-1; i++)
                //  wr.Write(contact[k][i]+" ");
                //wr.Write(contact[k][contact.Length-1]);
                //all = all.Trim();
                wr.WriteLine(all.Trim());
                //wr.WriteLine();
                //molDic.CleanMolData();
                DebugClass.WriteMessage("Make finished");
            }
        }
Example #5
0
        public ClusterOutput RunSift(string dirName)
        {
            Options opt = new Options();

            opt.ReadDefaultFile();

            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);
            }

            listFiles = new List <string>(files.Length);
            foreach (var item in files)
            {
                listFiles.Add(item);
            }

            return(Shape());
        }
Example #6
0
        protected void InitMeasure(DCDFile dcd, string alignFile, bool flag, PDBMODE allAtoms, string refJuryProfile = null)
        {
            base.InitMeasure(dcd, alignFile, flag, refJuryProfile);
            DCDReader readDCD = new DCDReader(dcd);

            pdbs = new PDBFiles();
            readDCD.DCDPrepareReading(dcd.dcdFile, dcd.pdbFile);
            int  counter = 0;
            bool cont    = true;

            do
            {
                MemoryStream mStream = new MemoryStream();
                StreamWriter wStream = new StreamWriter(mStream);
                cont = readDCD.ReadAndSavePDB(wStream);
                string name = "Model" + counter++;
                mStream.Position = 0;
                pdbs.AddPDB(mStream, allAtoms, name);
            }while(cont);

            readDCD.FinishDCDReading();

            pdbs.FindReferenceSeq();
            pdbs.MakeAlignment(alignFile);
            structNames = CheckAvailableStructures();


            atomDic = pdbs.MakeAllAtomsDic();
        }
Example #7
0
        public Rmsd(List <string> fileNames, string alignFile, bool flag, PDBMODE allAtoms, string refJuryProfile = null)
            : base(fileNames, alignFile, flag, refJuryProfile)
        {
            dirSettings.Load();
            pdbs = new PDBFiles();

            pdbs.AddPDB(fileNames, allAtoms);
            pdbs.FindReferenceSeq();
            pdbs.MakeAlignment(null);
            opt         = new Optimization();
            structNames = CheckAvailableStructures();
            order       = true;
        }
Example #8
0
 protected void ReadPdbs(List <string> structures)
 {
     try
     {
         pdbs = new PDBFiles();
         foreach (var item in structures)
         {
             pdbs.AddPDB(item, PDBMODE.ONLY_SEQ);
             currentProgress++;
         }
         //  pdbs.AddPDB(structures, PDBMODE.ONLY_CA,ref currentV);
         //pdbs.AddPDB(structures, PDBMODE.ONLY_SEQ, ref currentV);
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
Example #9
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();
        }
Example #10
0
        protected void InitMeasure(List <string> fileNames, string alignFile, bool flag, PDBMODE allAtoms, string refJuryProfile = null)

        {
            base.InitMeasure(fileNames, alignFile, flag, refJuryProfile);
            dirSettings.Load();
            pdbs     = new PDBFiles();
            maxV     = fileNames.Count;
            currentV = 0;
            pdbs.AddPDB(fileNames, allAtoms, ref currentV);
            if (pdbs.molDic.Keys.Count == 0)
            {
                throw new Exception("Unable to read pdb data!!");
            }
            pdbs.FindReferenceSeq();
            if (pdbs.molDic.Count == 0)
            {
                throw new Exception("All pdb structures have been removed. No Data!");
            }
            pdbs.MakeAlignment(null);
            structNames = CheckAvailableStructures();
            order       = true;
            atomDic     = pdbs.MakeAllAtomsDic();
        }
Example #11
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;
        }
Example #12
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;
         }
Example #13
0
        public Rmsd(List <string> fileNames, string alignFile, bool flag, PDBMODE allAtoms,string refJuryProfile=null)
            : base(fileNames, alignFile, flag,refJuryProfile)
        {

            dirSettings.Load();
            pdbs = new PDBFiles();

            pdbs.AddPDB(fileNames, allAtoms);
            pdbs.FindReferenceSeq();
            pdbs.MakeAlignment(null);
            opt = new Optimization();
            structNames = CheckAvailableStructures();
            order = true;
        }
Example #14
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);
        }
Example #15
0
        public override void Run(DCDFile dcd)
        {
            DCDReader                dcdReader = new DCDReader(null);
            string                   modelName = null;
            int                      counter   = 0;
            string                   fileName;
            StreamWriter             wr;
            PDBFiles                 pdbs      = new PDBFiles();
            Dictionary <string, int> modelList = null;

            fileName = GetProfileFileName(dcd);

            if (File.Exists(fileName))
            {
                modelList = CheckFile(dcd);

                wr = File.AppendText(fileName);
            }
            else
            {
                wr = new StreamWriter(fileName);
            }

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

            dcdReader.DCDPrepareReading(dcd.dcdFile, dcd.pdbFile);
            bool cont = true;

            do
            {
                MemoryStream mStream = new MemoryStream();
                StreamWriter write   = new StreamWriter(mStream);
                cont = dcdReader.ReadAndSavePDB(write);

                modelName = "Model" + counter++;
                if (modelList == null || modelList.ContainsKey(modelName))
                {
                    continue;
                }

                mStream.Position = 0;
                if (this.GetType() == typeof(ContactProfile))
                {
                    pdbs.AddPDB(mStream, PDBMODE.ALL_ATOMS, modelName);
                }
                else
                {
                    pdbs.AddPDB(mStream, PDBMODE.ONLY_CA, modelName);
                }
                if (pdbs.molDic.ContainsKey(modelName))
                {
                    MakeProfiles(modelName, pdbs.molDic[modelName], wr);
                }
            }while (cont);

            dcdReader.FinishDCDReading();

            wr.Close();
        }
Example #16
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();
         *             PDBFiles pdbsNew = new PDBFiles();
         *             //Needed only for CATH
         *             string []cathFiles=Directory.GetFiles("F:\\CATH");
         *             Dictionary<string, Dictionary<string, string>> aux = new Dictionary<string, Dictionary<string, string>>();
         *             foreach(var item in cathFiles)
         *             {
         *                 if(item.Contains("COMBS"))
         *                     ReadCathFile(item, aux);
         *             }
         *
         *
         *
         *             //-----------------------
         *
         *
         *             maxV = files.Count;
         *             bool test=false;
         *             try
         *             {
         *                 foreach (var item in aux.Keys)
         *                 {
         *                     string strName;
         *
         * //if (!test && item.Contains("1vij"))
         *                         test = true;
         *
         *                     if (!test)
         *                         continue;
         *                     //strName = pdbs.AddPDB(item, PDBMODE.CA_CB);
         *                     strName = pdbs.AddPDB("F:\\cath_pdb\\"+item, PDBMODE.ONLY_CA,CHAIN_MODE.ALL);
         *
         *                  //   if(aux.ContainsKey(pdbs.molDic))
         *
         *                     if (strName != null)
         *                     {
         *                         if (!aux.ContainsKey(strName))
         *                             Console.WriteLine("UPS");
         *                         List<Chain> toRemove = new List<Chain>();
         *                         chainId.Clear();
         *                         pdbsNew.molDic.Clear();
         *                         MolData mol=new MolData();
         *                         mol.mol = new Molecule();
         *                         pdbsNew.molDic=new Dictionary<string,MolData>();
         *                         pdbsNew.molDic.Add(strName,mol);
         *                         char chStart = '0';
         *                         foreach (var chains in aux[strName].Keys)
         *                         {
         *                             if (!chains.Contains("_"))
         *                                 continue;
         *                             Console.WriteLine(chains);
         *                             Chain cc=pdbs.molDic[strName].mol.CuttMoleculeToSEQ(aux[strName][chains], chains.Substring(0, 1)[0]);
         *                             if(cc!=null)
         *                             {
         *                                 cc.ChainIdentifier = chStart;
         *                                 chainId.Add(chStart, chains);
         *                                 chStart++;
         *                                 pdbsNew.molDic[strName].mol.Chains.Add(cc);
         *                             }
         *                         }
         *                         if(pdbsNew.molDic[strName].mol.Chains.Count>0)
         *                             MakeProfiles(strName, pdbsNew.molDic[strName], wr);
         *                     }
         *                     pdbs.molDic.Clear();
         *                     currentProgress++;
         *                 }
         *             }
         *             catch (Exception ex)
         *             {
         *                 // wr.Close();
         *                 throw new Exception(ex.Message);
         *             }
         *
         *             wr.Close();
         *             currentProgress = maxV;
         *             return 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();

            chunk  = new float[dirSettings.numberOfCores][, ];
            center = new float[dirSettings.numberOfCores][];
            for (int i = 0; i < dirSettings.numberOfCores; i++)
            {
                chunk[i]  = new float[fragBagLibrary[0].GetLength(0), fragBagLibrary[0].GetLength(1)];
                center[i] = new float[3];
            }
            maxV = files.Count;
            try
            {
                resetEvents = new ManualResetEvent[dirSettings.numberOfCores];
                for (int i = 0; i < dirSettings.numberOfCores; i++)
                {
                    resetEvents[i] = new ManualResetEvent(false);
                }
                foreach (var item in files)
                {
                    string strName;
                    //strName = pdbs.AddPDB(item, PDBMODE.CA_CB);
                    if (dirSettings.mode == INPUTMODE.PROTEIN)
                    {
                        strName = pdbs.AddPDB(item, PDBMODE.ONLY_CA, CHAIN_MODE.ALL);
                    }
                    else
                    {
                        strName = pdbs.AddPDB(item, PDBMODE.ONLY_P, CHAIN_MODE.ALL);
                    }

                    //   if(aux.ContainsKey(pdbs.molDic))

                    if (strName != null)
                    {
                        MakeProfiles(strName, pdbs.molDic[strName], wr);
                    }
                    pdbs.molDic.Clear();
                    ErrorBase.ClearErrors();
                    Interlocked.Increment(ref currentProgress);
                }
            }
            catch (Exception ex)
            {
                // wr.Close();
                throw new Exception(ex.Message);
            }

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