def write_assoc(self, assoc):
        """
        Write a single association to a line in the output file
        """
        # Handle comment 'associations'
        if assoc.get("header", False):

            # Skip incoming gaf-version headers, as we created the version above already
            if re.match("![\s]*gaf.?version", assoc["line"]):
                return

            self._write(assoc["line"] + "\n")
            return

        subj = assoc['subject']

        db, db_object_id = self._split_prefix(subj)

        qualifier = "|".join(assoc["qualifiers"])
        # qualifier is | seperated string, filter on None removes empty strings in case qualifiers is empty
        if assoc['negated']:
            qualifier = "|".join(list(filter(None, ["NOT", qualifier])))

        goid = assoc['object']['id']

        ev = assoc['evidence']
        evidence = ev['type']
        withfrom = "|".join(ev['with_support_from'])
        reference = "|".join(ev['has_supporting_reference'])

        date = assoc['date']
        assigned_by = assoc['provided_by']

        annotation_properties = '' # TODO
        # if we have any subject extensions, list each one that has a "property" equal to "isoform", take the first one, and grab the "filler"
        gene_product_isoform = [e for e in assoc["subject_extensions"] if e["property"] == "isoform"][0]["filler"] if len(assoc["subject_extensions"]) > 0 else ""

        aspect = assoc['aspect']
        interacting_taxon_id = assoc["interacting_taxon"]
        taxon = self._full_taxon_field(self.normalize_taxon(subj['taxon']['id']), self.normalize_taxon(interacting_taxon_id))

        extension_expression = self._extension_expression(assoc['object_extensions'])

        vals = [db,
                db_object_id,
                subj.get('label'),
                qualifier,
                goid,
                reference,
                evidence,
                withfrom,
                aspect,
                subj["fullname"],
                "|".join(subj.get('synonyms',[])),
                subj.get('type'),
                taxon,
                date,
                assigned_by,
                extension_expression,
                gene_product_isoform]

        self._write_row(vals)
def write_assoc ( self , assoc ) : if assoc . get ( "header" , False ) : if re . match ( "![\s]*gaf.?version" , assoc [ "line" ] ) : return self . _write ( assoc [ "line" ] + "\n" ) return subj = assoc [ 'subject' ] db , db_object_id = self . _split_prefix ( subj ) qualifier = "|" . join ( assoc [ "qualifiers" ] ) if assoc [ 'negated' ] : qualifier = "|" . join ( list ( filter ( None , [ "NOT" , qualifier ] ) ) ) goid = assoc [ 'object' ] [ 'id' ] ev = assoc [ 'evidence' ] evidence = ev [ 'type' ] withfrom = "|" . join ( ev [ 'with_support_from' ] ) reference = "|" . join ( ev [ 'has_supporting_reference' ] ) date = assoc [ 'date' ] assigned_by = assoc [ 'provided_by' ] annotation_properties = '' gene_product_isoform = [ e for e in assoc [ "subject_extensions" ] if e [ "property" ] == "isoform" ] [ 0 ] [ "filler" ] if len ( assoc [ "subject_extensions" ] ) > 0 else "" aspect = assoc [ 'aspect' ] interacting_taxon_id = assoc [ "interacting_taxon" ] taxon = self . _full_taxon_field ( self . normalize_taxon ( subj [ 'taxon' ] [ 'id' ] ) , self . normalize_taxon ( interacting_taxon_id ) ) extension_expression = self . _extension_expression ( assoc [ 'object_extensions' ] ) vals = [ db , db_object_id , subj . get ( 'label' ) , qualifier , goid , reference , evidence , withfrom , aspect , subj [ "fullname" ] , "|" . join ( subj . get ( 'synonyms' , [ ] ) ) , subj . get ( 'type' ) , taxon , date , assigned_by , extension_expression , gene_product_isoform ] self . _write_row ( vals )
Write a single association to a line in the output file