Ich habe ein Problem mit meinem Code. Das Programm wurde entwickelt, um die Datei zu analysieren, sie mit den Informationen auszuwählen und sie in der Liste der Objekte der Klasse zu speichern.Objekt ist nicht definiert
Aber zuerst - es speichert sie nicht richtig. Tatsächlich speichert nichts, es gibt leere Aufzeichnungen zurück.
Ich habe versucht, ein Minimum an Code vollständig zu erstellen und daran zu arbeiten. Als nächstes funktioniert es nicht. Ich kann keine Objekte anzeigen, weiß nicht, ob sie in der Klasse korrekt gespeichert werden. Ich änderte auch das XML zu einem kleineren und einem Beispiel, um zu sehen, wenn die Suche ein Fehler ist.
Ich denke darüber lange nach, mir sind die Ideen ausgegangen, ich frage nach einem Hinweis.
Mindest Code
from xml.dom import minidom
class Prot():
def __init__(self, name=''):
self.name = name
def addname(self, name):
for k in range(len(entry_list)):
names = entry_list[k].getElementsByTagName("Names")
for u in range(len(names)):
nam = names[u].getElementsByTagName("Name")
name.append(nam[u].firstChild.nodeValue)
print(nam[u].firstChild.nodeValue)
xml = minidom.parse('RESIDUES.XML')
entry_list = xml.getElementsByTagName("Entry")
mod_list = []
for e in range(len(entry_list)):
m = Prot(e)
mod_list.append(m)
xml - ein Datensatz
<Entry id="AA0003">
<Header>
<Code>AA0003</Code>
<Dates>
<CreationDate>31-Mar-1995</CreationDate>
<StrucRevDate>31-Mar-1995</StrucRevDate>
<TextChngDate>30-Sep-2010</TextChngDate>
</Dates>
</Header>
<Names>
<Name>L-asparagine</Name>
<AlternateName>2,4-bis(azanyl)-4-oxobutanoic acid</AlternateName>
<AlternateName>2,4-diamino-4-oxobutanoic acid</AlternateName>
<AlternateName>2-amino-3-carbamoylpropanoic acid</AlternateName>
<AlternateName>2-amino-4-butanediamic acid</AlternateName>
<AlternateName>2-aminosuccinamic acid</AlternateName>
<AlternateName>2-aminosuccinic acid 4-amide</AlternateName>
<AlternateName>alpha-amino-beta-carbamylpropionic acid</AlternateName>
<AlternateName>alpha-aminosuccinamic acid</AlternateName>
<AlternateName>aspartic acid 4-amide</AlternateName>
<AlternateName>aspartic acid beta-amide</AlternateName>
<AlternateName>beta-asparagine</AlternateName>
<SystematicName>(2S)-2-amino-4-butanediamic acid</SystematicName>
<Xref>CAS:70-47-3</Xref>
<Xref>ChEBI:50347</Xref>
<Xref>PDBHET:ASN</Xref>
</Names>
<FormulaBlock>
<Formula>C 4 H 6 N 2 O 2</Formula>
<Weight type="chemical">114.10</Weight>
<Weight type="physical">114.042927</Weight>
</FormulaBlock>
<CorrectionBlock uids="AA0003" label="ASN">
<Formula>C 0 H 0 N 0 O 0</Formula>
<Weight type="chemical">0.00</Weight>
<Weight type="physical">0.000000</Weight>
</CorrectionBlock>
<CorrectionBlock uids="AA0004" label="ASP">
<Formula>C 0 H 1 N 1 O -1</Formula>
<Weight type="chemical">-0.98</Weight>
<Weight type="physical">-0.984016</Weight>
</CorrectionBlock>
<ReferenceBlock>
<Authors>
<Author>Vauquelin, L.N.</Author>
<Author>Robiquet, P.J.</Author>
</Authors>
<Citation>Ann. Chim. 57, 88-93, 1806</Citation>
<Title>
Découverte d'un nouveau principe végétal dans les Asperges (Asparagus sativus, Linn.) [The discovery of a new plant principle in asparagus (Asparagus sativus, L.)].
</Title>
<Note>article in French; isolation and naming</Note>
</ReferenceBlock>
<ReferenceBlock>
<Authors>
<Author>Drenth, J.</Author>
<Author>Jansonius, J.N.</Author>
<Author>Koekoek, R.</Author>
<Author>Swen, H.M.</Author>
<Author>Wolthers, B.G.</Author>
</Authors>
<Citation>Nature 218, 929-932, 1968</Citation>
<Title>Structure of papain.</Title>
<Xref>DOI:10.1038/218929a0</Xref>
<Xref>PMID:5681232</Xref>
<Note>
asparagine as an active site residue in a thiol proteinase
</Note>
</ReferenceBlock>
<ReferenceBlock>
<Authors>
<Anonymous/>
<Group>
IUPAC-IUB Joint Commission on Biochemical Nomenclature (JCBN)
</Group>
</Authors>
<Citation>Eur. J. Biochem. 138, 9-37, 1984</Citation>
<Title>
Nomenclature and symbolism for amino acids and peptides. Recommendations 1983.
</Title>
<Xref>DOI:10.1111/j.1432-1033.1984.tb07877.x</Xref>
<Xref>PMID:6692818</Xref>
<Note>
standard three-letter and one-letter symbols, and nomenclature
</Note>
</ReferenceBlock>
<ReferenceBlock>
<Authors>
<Author>Curnow, A.W.</Author>
<Author>Tumbula, D.L.</Author>
<Author>Pelaschier, J.T.</Author>
<Author>Min, B.</Author>
<Author>Soll, D.</Author>
</Authors>
<Citation>
Proc. Natl. Acad. Sci. U.S.A. 95, 12838-12843, 1998
</Citation>
<Title>
Glutamyl-tRNA(Gln) amidotransferase in Deinococcus radiodurans may be confined to asparagine biosynthesis.
</Title>
<Xref>DOI:10.1073/pnas.95.22.12838</Xref>
<Xref>PMID:9789001</Xref>
<Note>
"mischarged" aspartyl-tRNA(Asn) is amidated by glutamyl-tRNA(Gln) amidotransferase in Deinococcus radiodurans
</Note>
</ReferenceBlock>
<ReferenceBlock>
<Authors>
<Author>Paradisi, F.</Author>
<Author>Dean, J.L.</Author>
<Author>Geoghegan, K.F.</Author>
<Author>Engel, P.C.</Author>
</Authors>
<Citation>Biochemistry 44, 3636-3643, 2005</Citation>
<Title>
Spontaneous chemical reversion of an active site mutation: deamidation of an asparagine residue replacing the catalytic aspartic acid of glutamate dehydrogenase.
</Title>
<Xref>DOI:10.1021/bi047679u</Xref>
<Xref>PMID:15736973</Xref>
<Note>
an Asp to Asn mutation at an enzyme active site seemingly has partial activity; however, the asparagine form is shown to be inactive, and enhanced spontaneous deamidation results in the partial recovery of activity
</Note>
</ReferenceBlock>
<ReferenceBlock>
<Authors>
<Author>Kolodkin-Gal, I.</Author>
<Author>Hazan, R.</Author>
<Author>Gaathon, A.</Author>
<Author>Carmeli, S.</Author>
<Author>Engelberg-Kulka, H.</Author>
</Authors>
<Citation>Science 318, 652-655, 2007</Citation>
<Title>
A linear pentapeptide is a quorum-sensing factor required for mazEF-mediated cell death in Escherichia coli.
</Title>
<Xref>DOI:10.1126/science.1147248</Xref>
<Xref>PMID:17962566</Xref>
<Note>
enzymatic amidation of an aspartic acid residue in a peptide; the enzyme is currently identified by an activity that is different from the new activity
</Note>
</ReferenceBlock>
<Comment>
Some bacteria or archaea incorporate asparagine produced by the amidation of aspartyl-tRNA(Asn).
</Comment>
<GeneratingEnzyme>
<EnzymeName link="ASN">aspartate--tRNA(Asn) ligase (EC 6.1.1.23)</EnzymeName>
<EnzymeName link="ASN">
asparaginyl-tRNA synthase (glutamine-hydrolysing) (EC 6.3.5.6)
</EnzymeName>
<EnzymeName link="ASP">aspartate--ammonia ligase (EC 6.3.1.1)</EnzymeName>
</GeneratingEnzyme>
<SequenceCode link="ASN">
<SequenceSpec>N</SequenceSpec>
<Abbreviation>Asn</Abbreviation>
<Xref>PSI-MOD:00012</Xref>
</SequenceCode>
<SequenceCode link="ASP">
<SequenceSpec>D</SequenceSpec>
<Xref>PSI-MOD:01185</Xref>
</SequenceCode>
<Source>natural</Source>
<Features>
<Feature type="UniProt" key="act_site____n" link="ASN">ACT_SITE</Feature>
<Feature type="UniProt" key="mod_res__amidated aspartic acid__d" link="ASP">MOD_RES Amidated aspartic acid</Feature>
</Features>
<Image src="/images/AA0003.GIF" alt="DUMMY.GIF"/>
<Model src="/models/AA0003.PDB"/>
</Entry>
Es ist unklar, was Sie als Ergebnis erwarten. 'addname' wird nie aufgerufen. Iterating durch 'Bereich (len (entry_list))' ergibt 0, 1, 2, .. len-1 - möglicherweise nicht, was Sie erwarten? –
Es sollte hier nur L-Asparagin sein. Ich habe die Funktion aufgerufen Name hinzufügen, wenn 'für e in Bereich (len (entry_list)): m = Prot (e) mod_list.append (m)'. Ich erstelle eine neue Objektklasse, ist getan add name und fügt das Ergebnis der Liste der Objekte hinzu. Es ist korrekt? – tiq
Eine XML-Datei hat ein Wurzelelement. Wenn Sie in Ihrem Beispiel "einen Datensatz" schreiben, ist dies eine gewöhnliche Datei oder haben Sie mehrere "Entry" -Elemente in einem anderen Root-Element? –