Attachment 'InteractionRecord.py'
## Copyright 2007 by Jake Feala jfeala@gmail.com
class InteractionRecord:
"""An InteractionRecord object holds information about an interaction.
Main attributes:
id - Interaction identifier
source - Node identifier such as a locus tag (string)
target - Node identifier such as a locus tag (string)
directed - True if directed edge from source to target. False if
bidirectional (as in protein-protein interactions)
value - Numerical value such as p-value or strength (float)
Additional attributes:
source_aliases - Alternate node names, e.g. gene name (list of strings)
target_aliases - Alternate node names, e.g. gene name (list of strings)
type - Interaction type, e.g. protein-protein or protein-dna (string)
PMID - Pubmed ID of study in which interaction was discovered
db - Database origin of the interaction record
"""
def __init__(self, source="<unknown node>", target="<unknown node>", id = "<unknown id>",
directed = "False", value = None, source_aliases = None, target_aliases = None,
type = "<unknown type>", PMID = None, db = None):
self.source = source
self.target = target
self.id = id
self.directed = directed
if source_aliases is None:
self.source_aliases = []
if target_aliases is None:
self.target_aliases = []
self.type = type
self.value = value
if PMID is None:
self.PMID = ""
self.db = db
def __str__(self) :
lines = []
if self.id : lines.append("ID: %s" % self.id)
if self.directed:
lines.append("Source: %s" % self.source)
lines.append("Target: %s" % self.target)
else:
lines.append("Species 1: %s" % self.source)
lines.append("Species 2: %s" % self.target)
if self.source_aliases:
lines.append("Source aliases: ")
for alias in self.source_aliases:
lines.append("\t\t %s" % alias)
if self.target_aliases:
lines.append("Target aliases: ")
for alias in self.target_aliases:
lines.append("\t\t %s" % alias)
if self.type: lines.append("type: %s" % self.type)
if self.PMID: lines.append("PubMed ID: %s" % self.PMID)
if self.db: lines.append("Database origin: %s" % self.db)
return "\n".join(lines)
You are not allowed to view this page.
