예제 #1
0
    def test_aggregator_adduct_lookup(self):
        """ """

        result = self.mda.adduct_lookup(728.605042778354,
                                        ionmode='pos')['[M+H]+'][1]

        assert 'SLM:000391523' in [i.lab.db_id for i in result]

        swl_cer1p = [i for i in result if i.lab.db_id == 'SLM:000391523'][0]

        assert 'Ceramide phosphate (d42:2)' in swl_cer1p.lab.names
        assert '' not in swl_cer1p.lab.names
        assert '1P' in swl_cer1p.hg.sub

        lyp_cer1p = lipproc.LipidRecord(
            lab=lipproc.LipidLabel(
                db_id=None,
                db='lipyd.lipid',
                names=('Cer-1P(DH42:2)', ),
                formula='C42H82N1O6P1',
            ),
            hg=lipproc.Headgroup(main='Cer', sub=('1P', )),
            chainsum=lipproc.ChainSummary(
                c=42,
                u=2,
                typ=('Sph', 'FA'),
                attr=(lipproc.ChainAttr(sph='DH', ether=False, oh=()),
                      lipproc.ChainAttr(sph='', ether=False, oh=())),
            ),
            chains=(),
        )

        assert lyp_cer1p in list(result)
예제 #2
0
 def iterlines(self):
     """Iterates standard lines."""
     
     for subs, inst in self.subsproduct():
         
         full_name = inst.getname()
         
         chains = tuple(
             s.attrs.chain for s in subs if hasattr(s.attrs, 'chain')
         )
         chainsum = lipproc.sum_chains(chains)
         name = (
             (lipproc.summary_str(self.hg, chainsum),)
                 if self.hg and self.sum_only else
             (lipproc.full_str(self.hg, chains),)
                 if self.hg and not self.sum_only else
             ()
         )
         lab = lipproc.LipidLabel(
             db_id   = None,
             db      = 'lipyd.lipid',
             names   = name,
             formula = inst.formula,
         )
         rec = lipproc.LipidRecord(
             lab = lab,
             hg  = self.hg,
             chainsum = chainsum if chainsum.c else None,
             chains = () if self.sum_only else chains,
         )
         
         yield inst.mass, rec
예제 #3
0
    def test_is_subset_of(self):

        empty_lab = lipproc.LipidLabel(None, None, None, None)
        lnp = name.LipidNameProcessor()

        pe = lnp.process('Phosphatidylethanolamine')
        pe_361 = lnp.process('Phosphatidylethanolamine(36:1)')
        pe_180181 = lnp.process('Phosphatidylethanolamine(18:0/18:1)')
        pe = lipproc.LipidRecord(
            lab=empty_lab,
            hg=pe[0],
            chainsum=None,
            chains=(),
        )
        pe_361 = lipproc.LipidRecord(
            lab=empty_lab,
            hg=pe_361[0],
            chainsum=pe_361[1],
            chains=(),
        )
        pe_180181 = lipproc.LipidRecord(
            lab=empty_lab,
            hg=pe_180181[0],
            chainsum=pe_180181[1],
            chains=pe_180181[2],
        )

        assert pe_361 in pe
        assert pe_180181 in pe_361
        assert pe_180181 in pe

        cer_d_361 = lnp.process('Ceramide(d36:1)')
        cer_dh_361 = lnp.process('Ceramide(DH36:1)')
        cer_d_361 = lipproc.LipidRecord(
            lab=empty_lab,
            hg=cer_d_361[0],
            chainsum=cer_d_361[1],
            chains=(),
        )
        cer_dh_361 = lipproc.LipidRecord(
            lab=empty_lab,
            hg=cer_dh_361[0],
            chainsum=cer_dh_361[1],
            chains=(),
        )

        assert cer_d_361 not in cer_dh_361
        assert cer_dh_361 not in cer_d_361
예제 #4
0
파일: moldb.py 프로젝트: soerendip/lipyd
    def __iter__(self):

        for rec in sdf.SdfReader.__iter__(self):

            if ('EXACT_MASS' not in rec['annot']
                    or float(rec['annot']['EXACT_MASS']) == 0):

                try:
                    exmass = formula.Formula(rec['annot']['FORMULA']).mass
                except KeyError:
                    # if no exact mass it means
                    # this is a higher level category
                    continue
            else:
                exmass = float(rec['annot']['EXACT_MASS'])

            names = [
                rec['name'][nametype].strip()
                for nametype in ('COMMON_NAME', 'SYSTEMATIC_NAME')
                if nametype in rec['name']
            ]
            if 'SYNONYMS' in rec['name']:
                names.extend(n.strip()
                             for n in rec['name']['SYNONYMS'].split(';'))

            names = [n.strip() for n in names if n.strip()]

            hg, chainsum, chains = self.nameproc.process(names)

            liprec = lipproc.LipidRecord(
                lab=lipproc.LipidLabel(
                    db_id=rec['id'],
                    db='LipidMaps',
                    names=tuple(names),
                    formula=rec['annot']['FORMULA'],
                ),
                hg=hg,
                chainsum=chainsum,
                chains=chains,
            )

            yield exmass, liprec
예제 #5
0
파일: moldb.py 프로젝트: soerendip/lipyd
    def __iter__(self):

        for mol in self.itermol(obmol=False):

            if not mol.swl_exact_mass:
                continue

            hg, chainsum, chains = self.nameproc.process(mol.title)

            rec = lipproc.LipidRecord(lab=lipproc.LipidLabel(
                db_id=mol.db_id,
                db='SwissLipids',
                names=mol.title,
                formula=mol.swl_formula,
            ),
                                      hg=hg,
                                      chainsum=chainsum,
                                      chains=chains)

            # yielding mass and record
            yield mol.swl_exact_mass or np.nan, rec