示例#1
0
        public string AddPDB(string fileName, PDBMODE flag, CHAIN_MODE flagChain = CHAIN_MODE.SINGLE)
        {
            string name = Path.GetFileName(fileName);

            if (molDic != null && molDic.ContainsKey(name))
            {
                return(name);
            }
            try
            {
                MolData molD = new MolData(fileName, flag, mode, flagChain);
                if ((molD.mol == null || molD.mol.Chains == null || molD.mol.Chains.Count == 0))
                {
                    ErrorBase.AddErrors("PDB reading: file " + fileName + " is removed from consideration it looks that it has wrong format");
                    return(null);
                }
                molDic.Add(name, molD);

                return(name);
            }
            catch (IncorrectSideChainException ex)
            {
                ErrorBase.AddErrors("PDB reading: file " + fileName + " is removed from consideration because\n" + ex.Message);
            }
            catch (Exception ee)
            {
                ErrorBase.AddErrors("PDB reading: file " + fileName + " is removed from consideration because\n" + ee.Message);
            }
            return(null);
        }
示例#2
0
        public string AddPDB(MemoryStream stream, PDBMODE flag, string modelName)
        {
            try
            {
                MolData molD = new MolData();
                if (!molD.ReadMolData(stream, flag, modelName))
                {
                    return(null);
                }
                molDic.Add(modelName, molD);

                return(modelName);
            }
            catch (IncorrectSideChainException ex)
            {
                ErrorBase.AddErrors("PDB reading: file " + modelName + " is removed from consideration because\n" + ex.Message);
            }
            return(null);
        }
示例#3
0
        public static float[,] GetFullStructure(MolData mol)
        {
            float[,] structure = new float [mol.indexMol.Length,3];
            for (int i = 0; i < mol.indexMol.Length; i++)
                if (mol.indexMol[i] != -1 && mol.mol.Residues[mol.indexMol[i]].ResidueName != 'X')
                {
                    //Take only first Atom (should be CA)
                    Atom atom=mol.mol.Residues[mol.indexMol[i]].Atoms[0];
                    structure[i, 0] = atom.Position.X;
                    structure[i, 1] = atom.Position.Y;
                    structure[i, 2] = atom.Position.Z;

                }
                else
                {
                    structure[i, 0] = float.MaxValue;
                    structure[i, 1] = float.MaxValue;
                    structure[i, 2] = float.MaxValue;
                }

            return structure;
        }
示例#4
0
        public string AddPDB(MemoryStream stream, PDBMODE flag,string modelName)
        {
            try
            {
                MolData molD = new MolData();
                if (!molD.ReadMolData(stream, flag,modelName))
                {
                    return null;
                }
                molDic.Add(modelName, molD);

                return modelName;

            }
            catch (IncorrectSideChainException ex)
            {
                ErrorBase.AddErrors("PDB reading: file " + modelName+ " is removed from consideration because\n" + ex.Message);
            }
            return null;
        }
示例#5
0
        public string AddPDB(string fileName,PDBMODE flag,CHAIN_MODE flagChain=CHAIN_MODE.SINGLE)
        {
            string name = Path.GetFileName(fileName);
            if(molDic!=null && molDic.ContainsKey(name))            
                return name;
            try
            {
                MolData molD = new MolData(fileName, flag,mode,flagChain);
                if ((molD.mol == null || molD.mol.Chains == null || molD.mol.Chains.Count == 0))
                {
                    ErrorBase.AddErrors("PDB reading: file " + fileName + " is removed from consideration it looks that it has wrong format");
                    return null;
                }
                molDic.Add(name, molD);

                return name;

            }
            catch (IncorrectSideChainException ex)
            {
                ErrorBase.AddErrors("PDB reading: file " + fileName + " is removed from consideration because\n" + ex.Message);
            }
            catch (Exception ee)
            {
                ErrorBase.AddErrors("PDB reading: file " + fileName + " is removed from consideration because\n" + ee.Message);
            }
            return null;
        }
示例#6
0
         protected override void MakeProfiles(string strName, MolData molDic,StreamWriter wr)
         {
              Dictionary<int, List<int>> contacts = new Dictionary<int, List<int>>();
              double[] dist2;              
             if(molDic!=null)             
             {
                 char []statesTab=Enumerable.Repeat<char>('N',molDic.mol.Residues.Count).ToArray();

                 molDic.CreateCAContactMap(8.5f, false);
                //pdbs.molDic[strName].CreateContactMap(9.5f, "CB");


                 foreach (var contItem in molDic.contactMap.Keys)
                {
                    if (!contacts.ContainsKey(contItem))
                        contacts.Add(contItem, new List<int>());


                    foreach (var itemList in molDic.contactMap[contItem])
                    {
                        contacts[contItem].Add((int)itemList);
                        if (!contacts.ContainsKey((int)itemList))
                        {
                            contacts.Add((int)itemList, new List<int>());
                            contacts[(int)itemList].Add(contItem);
                        }
                        else
                            if (!contacts[(int)itemList].Contains(contItem))
                                contacts[(int)itemList].Add(contItem);

                    }
                }
                int num;
                string profile = "";
                int len = molDic.mol.Chains[0].chainSequence.Length;
                for (int i = 0; i < len; i++)
                {

                    if (contacts.ContainsKey(i))
                    {
                        num = contacts[i].Count;
                        if (num > 9)
                            num = 9;
                    }
                    else
                        num = 0;
                    profile += num;
                    if (i < len - 1)
                        profile += " ";
                }
                dist2 = new double[molDic.mol.Residues.Count - 2];
                for (int i = 0; i < molDic.mol.Residues.Count - 2; i++)
                {

                    Atom aux1 = molDic.mol.Residues[i].Atoms[0];
                    Atom aux2 = molDic.mol.Residues[i + 2].Atoms[0];
                    double sum = (aux1.Position.X - aux2.Position.X) * (aux1.Position.X - aux2.Position.X);
                    sum += (aux1.Position.Y - aux2.Position.Y) * (aux1.Position.Y - aux2.Position.Y);
                    sum += (aux1.Position.Z - aux2.Position.Z) * (aux1.Position.Z - aux2.Position.Z);
                    sum = Math.Sqrt(sum);
                    dist2[i] = sum;                                            
                }
                for (int i = 0; i < molDic.mol.Residues.Count - 4; i++)
                {
                    Atom aux1 = molDic.mol.Residues[i].Atoms[0];
                    Atom aux2 = molDic.mol.Residues[i + 4].Atoms[0];
                    double sum = (aux1.Position.X - aux2.Position.X) * (aux1.Position.X - aux2.Position.X);
                    sum += (aux1.Position.Y - aux2.Position.Y) * (aux1.Position.Y - aux2.Position.Y);
                    sum += (aux1.Position.Z - aux2.Position.Z) * (aux1.Position.Z - aux2.Position.Z);
                    sum = Math.Sqrt(sum);
                    if(dist2[i]>4 && dist2[i]<8)
                    {
                        if(dist2[i]<6)
                        {
                            if(sum>4 && sum<14)
                            {
                                if(sum<7)
                                    statesTab[i] = 'H';
                                else
                                    if(sum<9)
                                        statesTab[i] = 'J';
                                    else
                                        if(sum<11)
                                            statesTab[i] = 'K';
                                        else
                                            if(sum<13)
                                                statesTab[i] = 'L';
                            }
                            else
                                statesTab[i] = 'U';//unphysical
                        }
                        else
                            if (sum > 4 && sum < 14)
                            {
                                if (sum < 7)
                                    statesTab[i] = 'E';
                                else
                                    if (sum < 9)
                                        statesTab[i] = 'R';
                                    else
                                        if (sum < 11)
                                            statesTab[i] = 'T';
                                        else
                                            if (sum < 13)
                                                statesTab[i] = 'Y';
                            }

                    }
                    else                   
                        statesTab[i] = 'U';//unphysical                                  

                }



                string ss = new string(statesTab);

                 if (profile.Length > 0)
                 {
                     wr.WriteLine(">" + strName);
                     wr.WriteLine(contactProfile + profile);                
                     wr.WriteLine(ssProfile + ss);
                     wr.WriteLine(SEQprofile + molDic.mol.Chains[0].chainSequence);

                 }

                 molDic.CleanMolData();
             }

         }
示例#7
0
        public static posMOL PrepareData(MolData mol1,MolData mol2,bool atomList=false)
        {
            int count=0;
            posMOL globPosMol = new posMOL();
            Dictionary<string, int> atomNameMol1 = null;

            for (int i = 0; i < mol1.mol.Residues.Count; i++)
                if (mol1.mol.Residues[i].Atoms.Count > count)
                    count = mol1.mol.Residues[i].Atoms.Count;
           
           atomNameMol1 = new Dictionary<string, int>(count);

            count = 0;
            for (int i = 0; i < mol1.indexMol.Length; i++)
                if (mol1.indexMol[i] != -1 && mol2.indexMol[i] != -1)// && mol1.mol.Residues[mol1.indexMol[i]].ResidueName != 'X' && mol2.mol.Residues[mol2.indexMol[i]].ResidueName != 'X')
                {
                    atomNameMol1.Clear();
                    List<Atom> atoms = mol1.mol.Residues[mol1.indexMol[i]].Atoms;
                    for (int j = 0; j < atoms.Count;j++ )
                        atomNameMol1.Add(atoms[j].AtomName, j);

                    foreach (var item in mol2.mol.Residues[mol2.indexMol[i]].Atoms)
                        if (atomNameMol1.ContainsKey(item.AtomName))
                            count++;
                }
           // index1 = mol1.indexMol;
            //index2 = mol2.indexMol;

            if (globPosMol.posmol1==null || count != globPosMol.posmol1.GetLength(0))
            {
                globPosMol.posmol1 = new float[count, 3];
                globPosMol.posmol2 = new float[count, 3];
            }
            if (atomList)
            {
                globPosMol.atoms = new List<string>[mol1.indexMol.Length];
                for(int i=0;i<mol1.indexMol.Length;i++)
                {
                    globPosMol.atoms[i] = new List<string>();
                }
            }

            count = 0;            
            for (int i = 0; i < mol1.indexMol.Length; i++)
                if (mol1.indexMol[i] != -1 && mol2.indexMol[i] != -1)// && mol1.mol.Residues[mol1.indexMol[i]].ResidueName != 'X' && mol2.mol.Residues[mol2.indexMol[i]].ResidueName != 'X')
                {
                    atomNameMol1.Clear();
                    List<Atom> atoms = mol1.mol.Residues[mol1.indexMol[i]].Atoms;
                    for (int j = 0; j < atoms.Count; j++)
                        atomNameMol1.Add(atoms[j].AtomName, j);

                    foreach (var item in mol2.mol.Residues[mol2.indexMol[i]].Atoms)
                        if (atomNameMol1.ContainsKey(item.AtomName))
                        {
                            Atom aux = mol1.mol.Residues[mol1.indexMol[i]].Atoms[atomNameMol1[item.AtomName]];
                            globPosMol.posmol1[count, 0] = aux.Position.X;
                            globPosMol.posmol1[count, 1] = aux.Position.Y;
                            globPosMol.posmol1[count, 2] = aux.Position.Z;
                            
                            globPosMol.posmol2[count, 0] = item.Position.X;
                            globPosMol.posmol2[count, 1] = item.Position.Y;
                            globPosMol.posmol2[count, 2] = item.Position.Z;
                            if(atomList)
                                globPosMol.atoms[i].Add(item.AtomName);
                            count++;
                        }
                }

            float[] center = new float[3];
            
            CenterMol(globPosMol.posmol1, center);
            CenterMol(globPosMol.posmol2, center);

            return globPosMol;
        }
示例#8
0
        protected virtual void MakeProfiles(string strName,MolData molDic, StreamWriter wr)
        {
            Dictionary<int, List<int>> contacts = new Dictionary<int, List<int>>();
            if (molDic != null)
            {
                residuePsi = new short[molDic.mol.Residues.Count];
                residuePhi = new short[molDic.mol.Residues.Count];

                if (!CalcAllDihedrals(molDic))
                    return;
                molDic.CreateSideChainContactMap(8.5f, false);
                //pdbs.molDic[strName].CreateContactMap(9.5f, "CB");


                foreach (var contItem in molDic.contactMap.Keys)
                {
                    if (!contacts.ContainsKey(contItem))
                        contacts.Add(contItem, new List<int>());


                    foreach (var itemList in molDic.contactMap[contItem])
                    {
                        contacts[contItem].Add((int)itemList);
                        if (!contacts.ContainsKey((int)itemList))
                        {
                            contacts.Add((int)itemList, new List<int>());
                            contacts[(int)itemList].Add(contItem);
                        }
                        else
                            if (!contacts[(int)itemList].Contains(contItem))
                                contacts[(int)itemList].Add(contItem);

                    }
                }

                int num;
                string profile = "";
                int len = molDic.mol.Chains[0].chainSequence.Length;
                for (int i = 0; i < len; i++)
                {

                    if (contacts.ContainsKey(i))
                    {
                        num = contacts[i].Count;
                        if (num > 9)
                            num = 9;
                    }
                    else
                        num = 0;
                    profile += num;
                    if (i < len - 1)
                        profile += " ";
                }
                string psiProfile = "";
                string phiProfile = "";
                string ss = "";
                List<string> meso = new List<string>();
                List<string> mesoDF = new List<string>();
                for (int i = 0; i < molDic.mol.Residues.Count; i++)
                {
                    string key;
                    psiProfile += residuePsi[i];
                    phiProfile += residuePhi[i];
                    key = BuildKey(residuePhi[i], residuePsi[i]);
                    meso.Add(key);
                    if (i < molDic.mol.Residues.Count - 1)
                    {
                        ss += " ";
                        psiProfile += " ";
                        phiProfile += " ";
                    }

                }
                char[] ssStates = new char[meso.Count];
                for (int i = 0; i < meso.Count; i++)
                    ssStates[i] = 'C';
                for (int i = 0; i < meso.Count; i++)
                {
                    if (meso[i] == null)
                        continue;


                    if (mesoStates.ContainsKey(meso[i]))
                    {
                        //mesoDF.Add(mesoStates[meso[i]]);
                        if (PII.ContainsKey(mesoStates[meso[i]]))
                            ssStates[i] = 'P';

                        if (i < meso.Count - 1)
                        {
                            if (meso[i + 1] != null && mesoStates.ContainsKey(meso[i + 1]))
                            {
                                string combStates = mesoStates[meso[i]] + mesoStates[meso[i + 1]];
                                if (turns.ContainsKey(combStates))
                                {
                                    ssStates[i] = ssStates[i + 1] = 'T';
                                }
                            }
                        }
                    }
                }
                for (int i = 0; i < meso.Count; i++)
                {
                    int counter = 0;
                    if (meso[i] == null)
                        continue;
                    if (mesoStates.ContainsKey(meso[i]))
                    {
                        if (helix.ContainsKey(mesoStates[meso[i]]) && i < meso.Count - 5)
                        {

                            for (int k = 0; k < 5; k++)
                                if (meso[i + k] != null && mesoStates.ContainsKey(meso[i + k]) && helix.ContainsKey(mesoStates[meso[i + k]]))
                                    counter++;
                                else
                                    break;
                            if (counter == 5)
                                for (int k = 0; k < 5; k++)
                                    ssStates[i + k] = 'H';
                        }
                        counter = 0;
                        if (i < meso.Count - 3)
                        {
                            for (int k = 0; k < 3; k++)
                            {
                                if (meso[i + k] != null && mesoStates.ContainsKey(meso[i + k]) && strand.ContainsKey(mesoStates[meso[i + k]]))
                                    counter++;
                                else
                                    break;
                            }
                            if (counter == 3)
                                for (int k = 0; k < 3; k++)
                                    if (ssStates[i + k] == 'C' || ssStates[i + k] == 'P')
                                        ssStates[i + k] = 'E';
                        }
                    }

                }

                ss = new string(ssStates);

                if (profile.Length > 0)
                {
                    wr.WriteLine(">" + strName);
                    wr.WriteLine(contactProfile + profile);
                    //wr.WriteLine(PsiProfile+psiProfile);
                    //wr.WriteLine(PhiProfile+phiProfile);
                    wr.WriteLine(ssProfile + ss);
                    wr.WriteLine(SEQprofile + molDic.mol.Chains[0].chainSequence);

                }

                molDic.CleanMolData();
            }

        }
示例#9
0
        public bool CalcAllDihedrals(MolData molDic)
        {
            Dictionary<string, Point3D> pfAtoms = new Dictionary<string, Point3D>() { { "CA", null }, { "C", null }, { "N", null }, { "PrevC", null }, { "NextN", null } };
            short result = 360;

            
            residuePsi[0]= result;

            if (!CheckIfAllNeededAtomsExists(molDic))
                return false;

            for (int i = 0; i < molDic.mol.Residues.Count; i++)
            {

                foreach (var item in molDic.mol.Residues[i].Atoms)
                {
                    if (pfAtoms.ContainsKey(item.AtomName))
                        pfAtoms[item.AtomName] = item.Position;
                }

                if (i > 0)
                    residuePhi[i]=(short)Math.Round(CalculateDihedralAngles(pfAtoms["PrevC"], pfAtoms["N"], pfAtoms["CA"], pfAtoms["C"]));
                else
                    residuePhi[i] = 360;
                if (i < molDic.mol.Residues.Count - 1)
                {
                    foreach (var item in molDic.mol.Residues[i + 1].Atoms)
                    {
                        if (item.AtomName == "N")
                        {
                            pfAtoms["NextN"] = item.Position;
                            break;
                        }
                    }
                    residuePsi[i] = (short)Math.Round(CalculateDihedralAngles(pfAtoms["N"], pfAtoms["CA"], pfAtoms["C"], pfAtoms["NextN"]));

                }
                else
                    residuePsi[i] = 360;

                pfAtoms["PrevC"] = pfAtoms["C"];
            }
            return true;
        }
示例#10
0
 private bool CheckIfAllNeededAtomsExists(MolData molDic)
 {
     List<Residue> rList = molDic.mol.Chains[0].Residues;
     for (int i = 0; i < rList.Count; i++)
     {
         int counter = 0;
         for (int j = 0; j < rList[i].Atoms.Count; j++)
         {
             switch (rList[i].Atoms[j].AtomName)
             {
                 case "CA":
                 case "N":
                 case "C":
                     counter++;
                     break;
             }
         }
         if (counter < 3)
             return false;
     }
     return true;
 }
示例#11
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]);
               wr.WriteLine(all);
               //wr.WriteLine();
               //molDic.CleanMolData();
               DebugClass.WriteMessage("Make finished");
           }
          
       }
示例#12
0
 protected virtual void GenerateContactMap(MolData mol,int k)
  {
      mol.CreateFullContactMap(8.5f, contact[k],"CA");               
  }
 protected override void GenerateContactMap(MolData mol, int k)
 {
     mol.CreateFullContactMap(15.5f, contact[k],"P");
 }