Biopython Tutorial und Kochbuch Japanische Übersetzung (4.2)

4.2 Creating a SeqRecord Zu 4.1

Using a SeqRecord object is not very complicated, since all of the information is presented as attributes of the class. ** Die Verwendung des SeqRecord-Objekts ist nicht so kompliziert, da alle Informationen explizit als Attribut der Klasse angegeben werden. ** ** **

Usually you won’t create a SeqRecord “by hand”, but instead use Bio.SeqIO to read in a sequence file for you (see Chapter 5 and the examples below). However, creating SeqRecord can be quite simple. ** Normalerweise erstellen Sie das SeqRecord-Objekt nicht selbst, sondern verwenden Bio.SeqIO, um es aus der Sequenzdatei zu lesen. (Siehe Kapitel 5 und das Beispiel unten) Das Generieren eines SeqRecord ist jedoch sehr einfach. ** ** **

4.2.1 SeqRecord objects from scratch

To create a SeqRecord at a minimum you just need a Seq object: ** Sie können ein minimales SeqRecord-Objekt erstellen, indem Sie einfach die Seq-Klasse verwenden. ** ** **


>>> from Bio.Seq import Seq
>>> simple_seq = Seq("GATC")
>>> from Bio.SeqRecord import SeqRecord
>>> simple_seq_r = SeqRecord(simple_seq)

Additionally, you can also pass the id, name and description to the initialization function, but if not they will be set as strings indicating they are unknown, and can be modified subsequently: ** Zusätzlich können ID, Name und Beschreibung bei der Initialisierung zugewiesen werden. Wenn Sie dies nicht tun, werden diese Werte mit unbekannt initialisiert, aber Sie können sie später ändern. ** ** **

>>> simple_seq_r.id
'<unknown id>'
>>> simple_seq_r.id = "AC12345"
>>> simple_seq_r.description = "Made up sequence I wish I could write a paper about"
>>> print(simple_seq_r.description)
Made up sequence I wish I could write a paper about
>>> simple_seq_r.seq
Seq('GATC')

Including an identifier is very important if you want to output your SeqRecord to a file. You would normally include this when creating the object: ** Wenn Sie SeqRecord als Datei ausgeben möchten, ist es sehr wichtig, ihm eine Kennung zu geben. Wird normalerweise beim Erstellen eines Objekts hinzugefügt. ** ** **

>>> from Bio.Seq import Seq
>>> simple_seq = Seq("GATC")
>>> from Bio.SeqRecord import SeqRecord
>>> simple_seq_r = SeqRecord(simple_seq, id="AC12345")

As mentioned above, the SeqRecord has an dictionary attribute annotations. This is used for any miscellaneous annotations that doesn’t fit under one of the other more specific attributes. ** Wie oben erwähnt, verfügt SeqRecord über ein Attribut vom Typ Wörterbuch, das als Annotation bezeichnet wird. Verwenden Sie diese Option für verschiedene Anmerkungen, die nicht in andere explizite Attribute passen. ** ** **

Adding annotations is easy, and just involves dealing directly with the annotation dictionary: ** Das Hinzufügen von Anmerkungen ist einfach. Fügen Sie sie einfach direkt in das Wörterbuch ein. ** ** **

>>> simple_seq_r.annotations["evidence"] = "None. I just made it up."
>>> print(simple_seq_r.annotations)
{'evidence': 'None. I just made it up.'}
>>> print(simple_seq_r.annotations["evidence"])
None. I just made it up.

Working with per-letter-annotations is similar, letter_annotations is a dictionary like attribute which will let you assign any Python sequence (i.e. a string, list or tuple) which has the same length as the sequence: ** Die Verwendung von Annotationen pro Buchstabe ist ähnlich. Letter_annotations kann Sequenzdaten im Wörterbuchtyp zuweisen. (d. h. String, Liste oder Tapple) **

>>> simple_seq_r.letter_annotations["phred_quality"] = [40, 40, 38, 30]
>>> print(simple_seq_r.letter_annotations)
{'phred_quality': [40, 40, 38, 30]}
>>> print(simple_seq_r.letter_annotations["phred_quality"])
[40, 40, 38, 30]

The dbxrefs and features attributes are just Python lists, and should be used to store strings and SeqFeature objects (discussed later in this chapter) respectively. ** Querverweise auf die Datenbank (.dbxrefs) und Feature-Informationen werden zum Speichern von Listentypen, Zeichenfolgen bzw. SeqFeature-Objekten verwendet. (Siehe später in diesem Kapitel) **

4.2.2 SeqRecord objects from FASTA files

This example uses a fairly large FASTA file containing the whole sequence for Yersinia pestis biovar Microtus str. 91001 plasmid pPCP1, originally downloaded from the NCBI. ** In diesem Beispiel wird eine ziemlich große FASTA-Datei verwendet, die die gesamte Sequenz von Yersinia pestis enthält. Ich habe es von NCBI heruntergeladen. ** ** **

This file is included with the Biopython unit tests under the GenBank folder, or online NC_005816.fna from our website. ** Die Datei mit dem Biopython-Komponententest befindet sich im GenBank-Ordner. Sie können die Datei auch von unserer Website herunterladen. ** ** **

The file starts like this - and you can check there is only one record present (i.e. only one line starting with a greater than symbol): ** Diese Datei beginnt wie folgt: Ich habe momentan nur eine Zeile (d. H. Eine Zeile, die mit dem Vorzeichen größer als beginnt) **

>gi|45478711|ref|NC_005816.1| Yersinia pestis biovar Microtus ... pPCP1, complete sequence
TGTAACGAACGGTGCAATAGTGATCCACACCCAACGCCTGAAATCAGATCCAGGGGGTAATCTGCTCTCC
...

Back in Chapter 2 you will have seen the function Bio.SeqIO.parse(...) used to loop over all the records in a file as SeqRecord objects. ** Wie wir in Kapitel 2 gesehen haben, durchläuft die Funktion Bio.SeqIO.parse (...) alle Datensätze in der SeqRecord-Objektdatei. ** ** **

The Bio.SeqIO module has a sister function for use on files which contain just one record which we’ll use here (see Chapter 5 for details): ** Hier verwenden wir eine ähnliche Schwesterfunktion aus dem Bio.SeqIO-Modul zum Lesen von Dateien mit nur einem Datensatz. (Details werden in Kapitel 5 angegeben.) **

Now, let’s have a look at the key attributes of this SeqRecord individually – starting with the seq attribute which gives you a Seq object: ** Schauen wir uns nun die Hauptattribute von SeqRecord an. Beim Zugriff auf das seq-Attribut wird ein Seq-Objekt zurückgegeben. ** ** **

>>> record.seq
Seq('TGTAACGAACGGTGCAATAGTGATCCACACCCAACGCCTGAAATCAGATCCAGG...CTG', SingleLetterAlphabet())

Here Bio.SeqIO has defaulted to a generic alphabet, rather than guessing that this is DNA. ** Bio.SeqIO hat das genetische Alphabet zurückgegeben, natürlich ist es DNA. ** ** **

If you know in advance what kind of sequence your FASTA file contains, you can tell Bio.SeqIO which alphabet to use (see Chapter 5). ** Wenn Sie im Voraus wissen, welche Sequenzdaten in der FASTA-Datei enthalten sein werden, können Sie angeben, welches Alphabet für das Bio.SeqIO-Modul verwendet werden soll (siehe Kapitel 5). ** ** **

Next, the identifiers and description: ** Weiter ist "Identifier" und "Description": **

>>> record.id
'gi|45478711|ref|NC_005816.1|'
>>> record.name
'gi|45478711|ref|NC_005816.1|'
>>> record.description
'gi|45478711|ref|NC_005816.1| Yersinia pestis biovar Microtus ... pPCP1, complete sequence'

As you can see above, the first word of the FASTA record’s title line (after removing the greater than symbol) is used for both the id and name attributes. ** Wie wir oben gesehen haben, wird der erste Buchstabe des Titels der Datensatzzeile in der FASTA-Datei (nach Entfernen des Zeichens größer als>) sowohl für die Attribute id als auch name verwendet. ** ** **

The whole title line (after removing the greater than symbol) is used for the record description. This is deliberate, partly for backwards compatibility reasons, but it also makes sense if you have a FASTA file like this: ** Die gesamte Titelzeile (nach Entfernen des Großzeichens>) wird zur Beschreibung des Datensatzes verwendet. Dies ist aus Gründen wie der Kompatibilität mit dem Backend. Und noch mehr mit den folgenden FASTA-Dateien. ** ** **

>Yersinia pestis biovar Microtus str. 91001 plasmid pPCP1
TGTAACGAACGGTGCAATAGTGATCCACACCCAACGCCTGAAATCAGATCCAGGGGGTAATCTGCTCTCC
...

Note that none of the other annotation attributes get populated when reading a FASTA file: ** Bitte beachten Sie, dass die anderen Attribute in der Anfangsphase der Übermittlung der FASTA-Datei leer sind. ** ** **

In this case our example FASTA file was from the NCBI, and they have a fairly well defined set of conventions for formatting their FASTA lines. ** In diesem Kurs werden unsere Beispiel-FASTA-Dateien aus NCBI entnommen und das Format der FASTA-Datensätze wird ziemlich gut beibehalten. ** ** **

This means it would be possible to parse this information and extract the GI number and accession for example. However, FASTA files from other sources vary, so this isn’t possible in general. ** Mit anderen Worten, es ist möglich, Informationen zu analysieren und GI-Nummern und zusätzliche Informationen zu extrahieren. Aber mit anderen Quellen wird es schwierig sein. ** ** **

4.2.3 SeqRecord objects from GenBank files

As in the previous example, we’re going to look at the whole sequence for Yersinia pestis biovar Microtus str. 91001 plasmid pPCP1, originally downloaded from the NCBI, but this time as a GenBank file. ** Im vorherigen Beispiel haben wir die gesamte Sequenz von Yersinia pestis-Bakterien gesehen, die von NCBI heruntergeladen wurden. Schauen wir uns diesmal die GenBank-Version an. ** ** **

Again, this file is included with the Biopython unit tests under the GenBank folder, or online NC_005816.gbfrom our website. ** Verwenden Sie in ähnlicher Weise eine Datei mit Biopython-Komponententest aus dem GenBank-Ordner oder laden Sie sie direkt von der Site herunter. ** ** **

This file contains a single record (i.e. only one LOCUS line) and starts: ** Diese Datei enthält einen einzelnen Datensatz (nur eine, d. H. LOCUS-Zeile) und startet **

LOCUS       NC_005816               9609 bp    DNA     circular BCT 21-JUL-2008
DEFINITION  Yersinia pestis biovar Microtus str. 91001 plasmid pPCP1, complete
            sequence.
ACCESSION   NC_005816
VERSION     NC_005816.1  GI:45478711
PROJECT     GenomeProject:10638
...

Again, we’ll use Bio.SeqIO to read this file in, and the code is almost identical to that for used above for the FASTA file (see Chapter 5 for details): ** Lesen Sie die Datei ebenfalls mit Bio.SeqIO und machen Sie es ähnlich wie für die FASTA-Datei. (Einzelheiten siehe Kapitel 5): **

>>> from Bio import SeqIO
>>> record = SeqIO.read("NC_005816.gb", "genbank")
>>> record
SeqRecord(seq=Seq('TGTAACGAACGGTGCAATAGTGATCCACACCCAACGCCTGAAATCAGATCCAGG...CTG',
IUPACAmbiguousDNA()), id='NC_005816.1', name='NC_005816',
description='Yersinia pestis biovar Microtus str. 91001 plasmid pPCP1, complete sequence.',
dbxrefs=['Project:10638'])

You should be able to spot some differences already! But taking the attributes individually, the sequence string is the same as before, but this time Bio.SeqIO has been able to automatically assign a more specific alphabet (see Chapter 5 for details): ** Sie sollten bereits einige Unterschiede entdeckt haben, aber schauen wir uns jeden an. Die Sequenz hat die gleichen Zeichenfolgen wie zuvor, aber diesmal konnte Bio.SeqIO den Typ des Alphabets genauer bestimmen. (Einzelheiten siehe Kapitel 5) **

The name comes from the LOCUS line, while the id includes the version suffix. The description comes from the DEFINITION line: ** Der Name ist die LOCUS-Zeile und die ID enthält die Versionsinformationen. Die Erklärung stammt aus der Zeile DEFINITION. ** ** **

GenBank files don’t have any per-letter annotations: ** Die GenBank-Datei enthält keine Annotation pro Brief. ** ** **

>>> record.letter_annotations
{}

Most of the annotations information gets recorded in the annotations dictionary, for example: ** Viele Anmerkungsinformationen werden im Anmerkungswörterbuch gespeichert. Zum Beispiel: **

>>> len(record.annotations)
11
>>> record.annotations["source"]
'Yersinia pestis biovar Microtus str. 91001'

The dbxrefs list gets populated from any PROJECT or DBLINK lines: ** Die Liste dbxrefs spiegelt den Inhalt der Zeile PROJECT oder DBLINK wider. ** ** **

>>> record.dbxrefs
['Project:10638']

Finally, and perhaps most interestingly, all the entries in the features table (e.g. the genes or CDS features) get recorded as SeqFeature objects in the features list. ** Schließlich werden am interessantesten alle Einträge in der Feature-Tabelle (z. B. Gene oder CDS-Features) in der Feature-Liste als SeqFeature-Objekte gespeichert. ** ** **

Recommended Posts

Biopython Tutorial und Kochbuch Japanische Übersetzung (4.3)
Biopython Tutorial und Kochbuch Japanische Übersetzung (4.1)
Biopython Tutorial und Kochbuch Japanische Übersetzung (4.5)
Biopython Tutorial und Kochbuch Japanische Übersetzung (4.8)
Biopython Tutorial und Kochbuch Japanische Übersetzung (4.7)
Biopython Tutorial und Kochbuch Japanische Übersetzung (4.9)
Biopython Tutorial und Kochbuch Japanische Übersetzung (4.6)
Biopython Tutorial und Kochbuch Japanische Übersetzung (4.2)
Biopython Tutorial und Kochbuch Japanische Übersetzung (4.4)
Biopython Tutorial und Kochbuch Japanische Übersetzung (Kapitel 1, 2)
Streamlit Tutorial Japanische Übersetzung
sosreport Japanische Übersetzung
[Übersetzung] Hyperopt-Tutorial
Mann systemd japanische Übersetzung
stromlinienförmige Erklärung japanische Übersetzung
Dockerfile Reference Japanische Übersetzung
Docker helfen japanische Übersetzung
SymPy Tutorial Japanische Notizen
[PyTorch] Tutorial (japanische Version) ② ~ AUTOGRAD ~
Docker Build - Hilfe japanische Übersetzung
Japanische Übersetzung des sysstat-Handbuchs
[PyTorch] Tutorial (japanische Version) ① ~ Tensol ~
Japanische Übersetzung des Linux-Handbuchs
Docker run --help japanische Übersetzung
Pandas Benutzerhandbuch "Tabellenformatierung und Pivot-Tabelle" (offizielles Dokument Japanische Übersetzung)