public void TitleTest() { AtomSource target = new AtomSource(); // TODO: Initialize to an appropriate value target.Title = new AtomTextConstruct(AtomTextConstructElementType.Title, "test"); Assert.AreEqual(target.Title.Text, "test"); }
/// <summary> /// Interpreta el origen de un nodo /// </summary> private AtomSource ParseSource(MLNode objMLSource) { AtomSource source = new AtomSource(); // Interpreta los datos del nodo foreach (MLNode node in objMLSource.Nodes) { switch (node.Name) { case AtomConstTags.cnstStrChannelId: source.ID = node.Value; break; case AtomConstTags.cnstStrChannelTitle: source.Title = node.Value; break; case AtomConstTags.cnstStrItemUpdated: source.DateUpdated = node.Value.GetDateTime(DateTime.Now); break; case AtomConstTags.cnstStrRights: source.Copyright = node.Value; break; } } // Devuelve los datos return(source); }
public AtomSource ToAtom() { AtomSource a = new AtomSource(); a.Name = (string)Values["name"]; a.X = (float)Values["x"]; a.Y = (float)Values["y"]; a.Z = (float)Values["z"]; a.ChainIndex = (Char)Values["chainID"]; a.ResidueName = (String)Values["resName"]; a.PdbResidueIndex = (int)Values["resSeq"]; a.ResidueIndex = (int)Values["resSeq"] - 1; a.Index = (int)Values["serial"] - 1; a.PdbAltLoc = (Char)Values["altLoc"]; a.Element = Element.Undefined; if (Values.ContainsKey("element")) { a.ElementName = (string)Values["element"]; a.Element = GetElement((string)Values["element"]); } else if (!String.IsNullOrEmpty(a.Name)) { // PDBs generated by ilmm don't have 'element' fields, even though // they should. a.Element = GetElement(a.Name.Substring(0, 1)); } return(a); }
/// <summary> /// Provides example code for the AtomSource class. /// </summary> public static void ClassExample() { AtomFeed feed = new AtomFeed(); feed.Id = new AtomId(new Uri("urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6")); feed.Title = new AtomTextConstruct("Example Feed"); feed.UpdatedOn = new DateTime(2003, 12, 13, 18, 30, 2); feed.Links.Add(new AtomLink(new Uri("http://example.org/"))); feed.Links.Add(new AtomLink(new Uri("/feed"), "self")); feed.Authors.Add(new AtomPersonConstruct("John Doe")); AtomEntry entry = new AtomEntry(); entry.Id = new AtomId(new Uri("urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a")); entry.Title = new AtomTextConstruct("Atom-Powered Robots Run Amok"); entry.UpdatedOn = new DateTime(2003, 12, 13, 18, 30, 2); entry.Summary = new AtomTextConstruct("Some text."); // Entry was copied from another feed, so preserve source meta-data AtomSource source = new AtomSource(); source.Id = new AtomId(new Uri("http://example2.org/")); source.Title = new AtomTextConstruct("Fourty-Two"); source.UpdatedOn = new DateTime(2003, 11, 13, 18, 30, 2); source.Rights = new AtomTextConstruct("© 2003 Example, Inc."); entry.Source = source; feed.AddEntry(entry); }
public void AtomSourceConstructorTest() { AtomFeed feed = new AtomFeed(new Uri("http://www.test.com/"), null); feed.Title = new AtomTextConstruct(AtomTextConstructElementType.Title, "Title"); AtomSource target = new AtomSource(feed); Assert.AreEqual(feed.Title.Text, target.Title.Text); }
///////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// /// <summary>reads one external feed and inserts it locally</summary> ////////////////////////////////////////////////////////////////////// [Test] public void DefaultHostInsertExternalFeed() { Tracing.TraceMsg("Entering DefaultHostInsertExternalFeed"); if (this.strRemoteHost != null) { // remove old data DefaultHostDeleteAll(); FeedQuery query = new FeedQuery(); Service service = new Service(); service.RequestFactory = (IGDataRequestFactory) new GDataLoggingRequestFactory(this.ServiceName, this.ApplicationName); query.Uri = new Uri(this.strRemoteHost); AtomFeed remoteFeed = service.Query(query); query.Uri = new Uri(this.defaultHost); AtomFeed localFeed = service.Query(query); foreach (AtomEntry remoteEntry in remoteFeed.Entries) { localFeed.Entries.Add(remoteEntry); Tracing.TraceInfo("added: " + remoteEntry.Title.Text); } bool f; foreach (AtomEntry localEntry in localFeed.Entries) { f = localEntry.IsDirty(); Assert.AreEqual(true, f, "This entry better be dirty now"); } f = localFeed.IsDirty(); Assert.AreEqual(true, f, "This feed better be dirty now"); localFeed.Publish(); foreach (AtomEntry localEntry in localFeed.Entries) { f = localEntry.IsDirty(); Assert.AreEqual(false, f, "This entry better NOT be dirty now"); } f = localFeed.IsDirty(); Assert.AreEqual(false, f, "This feed better NOT be dirty now"); // requery localFeed = service.Query(query); foreach (AtomEntry localEntry in localFeed.Entries) { AtomSource source = localEntry.Source; Assert.AreEqual(source.Id.Uri.ToString(), remoteFeed.Id.Uri.ToString(), "This entry better has the same source ID than the remote feed"); } } }
public void LogoTest() { AtomSource target = new AtomSource(); // TODO: Initialize to an appropriate value AtomLogo expected = new AtomLogo(); AtomLogo actual; target.Logo = expected; actual = target.Logo; Assert.AreEqual(expected, actual); }
public void GeneratorTest() { AtomSource target = new AtomSource(); // TODO: Initialize to an appropriate value AtomGenerator expected = new AtomGenerator(); AtomGenerator actual; target.Generator = expected; actual = target.Generator; Assert.AreEqual(expected, actual); }
public void IconTest() { AtomSource target = new AtomSource(); // TODO: Initialize to an appropriate value AtomIcon expected = new AtomIcon(); AtomIcon actual; target.Icon = expected; actual = target.Icon; Assert.AreEqual(expected, actual); }
public void IdTest() { AtomSource target = new AtomSource(); // TODO: Initialize to an appropriate value AtomId expected = new AtomId(); AtomId actual; target.Id = expected; actual = target.Id; Assert.AreEqual(expected, actual); }
public void UpdatedTest() { AtomSource target = new AtomSource(); // TODO: Initialize to an appropriate value DateTime expected = DateTime.Now; DateTime actual; target.Updated = expected; actual = target.Updated; Assert.AreEqual(expected, actual); }
/// <summary> /// Añade los datos del origen /// </summary> private void AddSource(MLNode parent, AtomSource source) { MLNode node = parent.Nodes.Add(AtomConstTags.cnstsource); // Cuerpo node.Nodes.Add(AtomConstTags.cnstStrChannelId, source.ID); node.Nodes.Add(AtomConstTags.cnstStrChannelTitle, source.Title); AddDate(node, AtomConstTags.cnstStrItemUpdated, source.DateUpdated); node.Nodes.Add(AtomConstTags.cnstStrRights, source.Copyright); }
public void SourceTest() { AtomEntry target = new AtomEntry(); // TODO: Initialize to an appropriate value AtomSource expected = new AtomSource(); AtomSource actual; target.Source = expected; actual = target.Source; Assert.AreEqual(expected, actual); }
///////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// /// <summary>compares 2 source objects</summary> /// <param name="theOne">the One source</param> /// <param name="theOther">the Other source</param> /// <returns>true if identical </returns> ////////////////////////////////////////////////////////////////////// public static bool IsSourceIdentical(AtomSource theOne, AtomSource theOther) { Tracing.TraceInfo("Comparing source objects"); if (theOne == null && theOther == null) { return(true); } if (!ObjectModelHelper.IsBaseIdentical(theOne, theOther)) { return(false); } Tracing.TraceInfo("Source: comparing Authors collections"); if (!ObjectModelHelper.IsPersonCollectionIdentical(theOne.Authors, theOther.Authors)) { return(false); } Tracing.TraceInfo("Source: comparing Contributors collections"); if (!ObjectModelHelper.IsPersonCollectionIdentical(theOne.Contributors, theOther.Contributors)) { return(false); } Tracing.TraceInfo("Source: comparing categories collections"); if (!ObjectModelHelper.IsCategoryCollectionIdentical(theOne.Categories, theOther.Categories)) { return(false); } Tracing.TraceInfo("Source: comparing links collections"); if (!ObjectModelHelper.IsLinkCollectionIdentical(theOne.Links, theOther.Links)) { return(false); } if (!ObjectModelHelper.IsTextConstructIdentical(theOne.Title, theOther.Title)) { return(false); } if (!ObjectModelHelper.IsTextConstructIdentical(theOne.Rights, theOther.Rights)) { return(false); } if (!ObjectModelHelper.IsTextConstructIdentical(theOne.Subtitle, theOther.Subtitle)) { return(false); } if (!ObjectModelHelper.IsBaseLinkIdentical(theOne.Id, theOther.Id)) { return(false); } if (!ObjectModelHelper.IsGeneratorIdentical(theOne.Generator, theOther.Generator)) { return(false); } if (!ObjectModelHelper.IsBaseLinkIdentical(theOne.Icon, theOther.Icon)) { return(false); } if (!ObjectModelHelper.IsBaseLinkIdentical(theOne.Logo, theOther.Logo)) { return(false); } return(true); }
public static IChain ChainFromRecords(IEnumerable <AtomRecord> records, PdbLoadOptions loadOptions = PdbLoadOptions.Default, char?chainId = null) { bool wellFormatted = (loadOptions) == PdbLoadOptions.WellFormatted; bool requireNCAC = (loadOptions & PdbLoadOptions.RequireNCAC) != 0; bool requireNonNCAC = (loadOptions & PdbLoadOptions.RequireNonNCAC) != 0; bool missingAtomsNaN = (loadOptions & PdbLoadOptions.MissingAtomsNaN) != 0; IEnumerable <AtomSource> allAtoms = records.Where(record => record != null).Select(record => record.ToAtom()); IEnumerable <IGrouping <char, AtomSource> > chains = allAtoms.GroupBy(atom => atom.ChainIndex); foreach (IGrouping <char, AtomSource> chain in chains) { bool chainFailed = false; char actualChainId = chain.Key; if (chainId != null && chainId != actualChainId) { continue; } Chain peptideQuick = new Chain(); List <IGrouping <int, AtomSource> > pdbResidues = chain.GroupBy(atom => atom.ResidueIndex).OrderBy(group => group.Key).ToList(); foreach (IGrouping <int, AtomSource> pdbResidue in pdbResidues) { bool nTerminus = pdbResidue == pdbResidues.First(); bool cTerminus = pdbResidue == pdbResidues.Last(); AtomSource N = pdbResidue.FirstOrDefault(atom => atom.Name == "N"); AtomSource CA = pdbResidue.FirstOrDefault(atom => atom.Name == "CA"); AtomSource C = pdbResidue.FirstOrDefault(atom => atom.Name == "C"); // Get the name and create the residue string name3 = pdbResidue.First().ResidueName; if (name3 == "HIS") // TODO: Is this the best way of doing this? { if (pdbResidue.FirstOrDefault(atom => atom.Name == "HD1" || atom.Name == "1HD") != null) { name3 = "HID"; } else { name3 = "HIE"; } } // Default to non-disulfide and then replace with disulfides when CYH are nearby with nearby SG atoms if (name3 == "CYS") { name3 = "CYH"; } if (!AaTable.IsResidueNameKnown(name3)) { // TODO: Handle ions in some way if ((new string[] { "ZN", "HOH", "H20", "AU", "CA", "MG", "SO4" }.Contains(name3))) { continue; } Console.WriteLine("Failing on unknown residue " + name3); chainFailed = true; break; } IAa residueQuick = new Aa(name3, nTerminus, cTerminus); // Check for existence of atoms if (N == null || CA == null || C == null) { if (requireNCAC) { // TODO: Tracer output chainFailed = true; break; } } else if (float.IsNaN(N.XYZ.Length()) || float.IsNaN(CA.XYZ.Length()) || float.IsNaN(C.XYZ.Length())) { if (requireNCAC) { // TODO: Tracer output chainFailed = true; break; } } else { residueQuick.AlignToNCAC(N.XYZ, CA.XYZ, C.XYZ); } if (missingAtomsNaN) { // Only explicitly PDB-defined atoms have real coordinates for (int i = 0; i < residueQuick.Count; i++) { residueQuick[i].Xyz = new Vector3(float.NaN, float.NaN, float.NaN); } } // Method 1 //foreach(AtomQuick atomQuick in residueQuick) //{ // AtomSource atomSource = pdbResidue.FirstOrDefault(atomPdb => atomPdb.Name == atomQuick.Name); // // Some PDBs are formatted with hydrogens like 2HD1 instead of HD12 // AtomSource alternateAtomSource = null; // if(atomQuick.Name.StartsWith("H") && Char.IsNumber(atomQuick.Name.Last())) { // string alternateName = atomQuick.Name.Last() + atomQuick.Name.Substring(0, atomQuick.Name.Length - 1); // alternateAtomSource = pdbResidue.FirstOrDefault(atomPdb => atomPdb.Name == alternateName); // } // if(atomSource != null) // { // atomQuick.XYZ = atomSource.XYZ; // } // else if (alternateAtomSource != null) // { // atomQuick.XYZ = alternateAtomSource.XYZ; // } // else if (!allowMissingAtoms) // { // // TODO ... return null? // continue; // } //} // Method 2 - explicit atom name alternatives // First pass: initialize atom locations based on exact name-matched PDB records List <IAtom> initializedAtoms = new List <IAtom>(); List <AtomSource> usedSourceAtoms = new List <AtomSource>(); List <IAtom> uninitializedAtoms = new List <IAtom>(residueQuick); foreach (IAtom atomQuick in residueQuick) { AtomSource atomSource = pdbResidue.FirstOrDefault(atomPdb => atomPdb.Name == atomQuick.Name); if (atomSource != null) { atomQuick.Xyz = atomSource.XYZ; initializedAtoms.Add(atomQuick); uninitializedAtoms.Remove(atomQuick); usedSourceAtoms.Add(atomSource); } } // Second pass: try to initialize any remaining atoms from PDB records corresponding to known alternative atom names. Multiple // passes are made to try to resolve the names, moving from more to less preferred. int alternateAtomNamesMaxCount = alternateAtomNames_.Values.Select(value => value.Count).Max(); for (int nameIndex = 0; nameIndex < alternateAtomNamesMaxCount; nameIndex++) { foreach (Atom atomQuick in residueQuick) { if (initializedAtoms.Contains(atomQuick)) { continue; } List <string> alternativeAtomNames = null; if (!alternateAtomNames_.TryGetValue(atomQuick.Name, out alternativeAtomNames)) { continue; } if (alternativeAtomNames.Count <= nameIndex) { continue; } IEnumerable <AtomSource> atomSources = pdbResidue.Where(atomPdb => alternativeAtomNames[nameIndex] == atomPdb.Name); foreach (AtomSource atomSource in atomSources) { if (usedSourceAtoms.Contains(atomSource)) { continue; } atomQuick.Xyz = atomSource.XYZ; initializedAtoms.Add(atomQuick); uninitializedAtoms.Remove(atomQuick); usedSourceAtoms.Add(atomSource); } } } if (initializedAtoms.Count != residueQuick.Count) { if (!requireNCAC && !requireNonNCAC) { continue; } IEnumerable <IAtom> uninitializedNCAC = uninitializedAtoms.Where(atom => atom.Name == "N" || atom.Name == "CA" || atom.Name == "C").Where(atom => float.IsNaN(atom.Xyz.Length())); IEnumerable <IAtom> uninitializedNonNCAC = uninitializedAtoms.Where(atom => atom.Name != "N" && atom.Name != "CA" && atom.Name != "C").Where(atom => float.IsNaN(atom.Xyz.Length())); if (requireNCAC && uninitializedNCAC.Count() > 0) { chainFailed = true; break; } if (requireNonNCAC && uninitializedNonNCAC.Count() > 0) { chainFailed = true; break; } //// TODO: Create trace output and move this there //Console.WriteLine("Failed to initialize residue " + residueQuick.Name); //foreach (AtomQuick atom in uninitializedAtoms) //{ // Console.WriteLine(atom.Name); //} //chainFailed = true; //break; } peptideQuick.Add(residueQuick); } if (!chainFailed && peptideQuick.Count > 0) { AddDisulfides(peptideQuick); return(peptideQuick); } } return(null); }
public void AuthorsTest() { AtomSource target = new AtomSource(); // TODO: Initialize to an appropriate value Assert.IsNotNull(target.Authors); }
public void AtomSourceConstructorTest1() { AtomSource target = new AtomSource(); Assert.IsNotNull(target); }
public void XmlNameTest() { AtomSource target = new AtomSource(); // TODO: Initialize to an appropriate value Assert.AreEqual(target.XmlName, AtomParserNameTable.XmlSourceElement); }