Ejemplo n.º 1
0
        private void LogBarrel(StrandGroupMaker myStrandGroup)
        {
            var numberOfStrands = 0;

            if (this.Success)
            {
                numberOfStrands = myStrandGroup.BarrelStrands.Count;
            }

            var chainID = "";

            if (this.barrelType == "mono")
            {
                chainID = myStrandGroup.BarrelStrands[0].ChainName;
            }
            else if (this.barrelType == "poly")
            {
                var curChain = myStrandGroup.BarrelStrands[0].ChainName;
                chainID += curChain;
                foreach (Strand curStrand in myStrandGroup.BarrelStrands)
                {
                    if (curStrand.ChainName != curChain)
                    {
                        curChain = curStrand.ChainName;
                        chainID += "," + curChain;
                    }
                }
            }
            else
            {
                chainID = "NA";
            }


            string logFileLoc = Global.OUTPUT_DIR + "Log.txt";

            using (StreamWriter log = File.AppendText(logFileLoc))
            {
                log.WriteLine("{0}\t{1}\t{2}\t{3}\t{4}", this.PdbName, this.Success, this.barrelType, chainID, numberOfStrands);
            }
        }
Ejemplo n.º 2
0
        //barrel constructor
        public AllBarrel(ref Protein newProt)
        {
            this.newProt     = newProt;
            this.PdbName     = newProt.PdbName;
            this.protoBarrel = new List <List <List <int> > >();
            this.Strands     = new List <Strand>();
            this.barrelType  = "NA";
            this.Success     = false;
            var resList = new List <Res>();
            StrandGroupMaker myStrandGroup = null;


            CreateStrandList(ref newProt);

            SharedFunctions.writePymolScriptForStrandsRik(Strands, Global.OUTPUT_DIR, Global.DB_DIR, PdbName);

            foreach (var chain in newProt.Chains)
            {
                foreach (var residue in chain)
                {
                    resList.Add(residue);
                }
            }

            #region find the barrel
            var isMonoFlag = false;
            var isPolyFlag = false;
            var flag       = true;
            #region Hard code some PolyBarrels
            if (new List <string>()
            {
                "5GAQ", "6RB9", "3W9T", "5WC3", "3ANZ", "4P1X", "5JZT"
            }.Contains(PdbName))
            {
                flag = false;
            }
            #endregion

            if (flag)
            {
                foreach (var chain in newProt.Chains)//check for each chain first
                {
                    var monoStrands = new List <Strand>();
                    foreach (var strand in this.Strands)
                    {
                        if (strand.ChainName == chain.ChainName)
                        {
                            monoStrands.Add(strand);
                        }
                    }
                    if (monoStrands.Count != 0)
                    {
                        Console.WriteLine($"Starting strandGroupMaker for Chain {chain.ChainName}");
                        myStrandGroup = new StrandGroupMaker(newProt, monoStrands);
                        if (myStrandGroup.GroupOfGroup.Any(group => group.IsBarrel == true))
                        {
                            isMonoFlag   = true;
                            this.Strands = myStrandGroup.BarrelStrands;
                            var group = myStrandGroup.GroupOfGroup.First(group => group.IsBarrel == true);
                            this.Ncentroid      = group.Ncentroid;
                            this.Ccentroid      = group.Ccentroid;
                            this.CellipseCoords = group.CellipseCoords;
                            this.NellipseCoords = group.NellipseCoords;
                            this.Axis           = group.Axis;

                            Console.WriteLine($"Protein {PdbName} Chain {chain.ChainName} has a Mono barrel with {myStrandGroup.BarrelStrands.Count} strands");
                            this.barrelType = "mono";
                            this.Success    = true;
                            //LogBarrel(myStrandGroup);

                            break;
                        }
                    }
                }
            }

            if (isMonoFlag == false)                //if all the chain comes back as negative then check for poly
            {
                this.Strands = new List <Strand>(); //reseting the list of strands as it gets modified by the single chain StrandGroupMaker
                CreateStrandList(ref newProt);
                //Console.WriteLine($"\nStarting strandGroupMaker for whole protein");
                myStrandGroup = new StrandGroupMaker(newProt, Strands);
                if (myStrandGroup.GroupOfGroup.Any(group => group.IsBarrel == true))
                {
                    isPolyFlag   = true;
                    this.Strands = myStrandGroup.BarrelStrands;
                    Console.WriteLine($"Protein {PdbName} has a Poly barrel with {myStrandGroup.BarrelStrands.Count} strands");
                    this.barrelType = "poly";
                    this.Success    = true;
                    //LogBarrel(myStrandGroup);
                }
            }
            #endregion

            if (!isMonoFlag && !isPolyFlag)
            {
                //LogBarrel(null);
            }
            else
            {
                this.Strands = myStrandGroup.BarrelStrands;
                var barrel_strand_ctr = 0;
                foreach (Strand strand in this.Strands)
                {
                    strand.StrandNum = barrel_strand_ctr++;
                    foreach (Res r in strand)
                    {
                        r.StrandNum = barrel_strand_ctr;
                    }
                }
                /* ---------output information from mono --------- */
                this.StrandLength = SharedFunctions.getStrandLengths(this.Strands, path, this.PdbName);
                //this.PrevTwists = SharedFunctions.writeTwists(this.Strands, Global.OUTPUT_DIR, this.PdbName);

                #region Amino Acid Pair
                try
                {
                    SharedFunctions.AminoAcidPairs(this.Strands, Global.OUTPUT_DIR, Global.DB_DIR, this.PdbName);
                }
                catch (Exception exception)
                {
                    Console.WriteLine("Failed to make pairs");
                    string fileLocation3 = Global.OUTPUT_DIR + "AAPairErrorLog.txt";
                    using (StreamWriter file3 = new StreamWriter(fileLocation3, append: true))
                    {
                        string newLine3 = this.PdbName + "\t" + exception.InnerException + exception.Message + "\t" + exception.StackTrace + "\t" + exception.Source + "\t" + exception.Data + "\n";
                        file3.WriteLine(newLine3);
                    }
                }
                #endregion


                if (PdbName == "2HLV")
                {
                    SharedFunctions.setInOut(this.Strands, path, this.PdbName, this.Axis, this.Ccentroid, this.Ncentroid);
                }
                else
                {
                    SharedFunctions.setInOutMin(this.Strands, Global.OUTPUT_DIR, this.PdbName, this.Ccentroid, this.Ncentroid);
                }

                SharedFunctions.WritePymolScriptForInOutStrands(this.Strands, Global.OUTPUT_DIR, Global.DB_DIR, PdbName, Ccentroid, Ncentroid);
                this.AvgTilt = SharedFunctions.getTiltsByAA(this.Strands, path, this.PdbName, this.Axis, ref Global.AADict);

                bool detail_variable_output = true;
                if (detail_variable_output == true)
                {
                    if (!System.IO.Directory.Exists(path + "detailCheck"))
                    {
                        System.IO.Directory.CreateDirectory(path + "detailCheck");
                    }

                    string fileLocation1 = path + "detailCheck/AllAtomVariables_" + this.PdbName + ".txt";
                    using (System.IO.StreamWriter file = new System.IO.StreamWriter(fileLocation1))
                    {
                        file.WriteLine("{0}\t{1}\t{2}\t{3}\t{4}\t{5}\t{6}\t{7}\t{8}\t{9}\t{10}\t{11}\t{12}\t{13}\t{14}t{15}", "strand.ChainName", "strand.ChainNum", "strand.betaStrandNum", "strand.StrandNum", "res.ThreeLetCode", "res.OneLetCode", "res.SeqID", "res.ResNum", "res.Inward", "res.Atoms.Count", "atom.AtomName", "atom.AtomNum", "atom.AtomType", "atom.Coords.X", "atom.Coords.Y", "atom.Coords.Z");

                        foreach (Strand strand in this.Strands)
                        {
                            foreach (Res res in strand)
                            {
                                foreach (Atom atom in res)
                                {
                                    if (atom.AtomName == "CA")
                                    {
                                        file.WriteLine("{0}\t{1}\t{2}\t{3}\t{4}\t{5}\t{6}\t{7}\t{8}\t{9}\t{10}\t{11}\t{12}\t{13}\t{14}\t{15}", strand.ChainName, strand.ChainNum, strand.betaStrandNum, strand.StrandNum, res.ThreeLetCode, res.OneLetCode, res.SeqID, res.ResNum, res.Inward, res.Atoms.Count, atom.AtomName, atom.AtomNum, atom.AtomType, atom.Coords.X, atom.Coords.Y, atom.Coords.Z);
                                    }
                                }
                            }
                        }
                    }
                }
                SharedFunctions.writePymolScriptForBarrelStrands(this.Strands, Global.OUTPUT_DIR, Global.DB_DIR, this.PdbName);
            }

            this.Success = true;
        }