コード例 #1
0
    def CheckLink(self, query_nid, query_from, query_to, sbjct_nid, sbjct_from,
                  sbjct_to):
        """check, whether link is faithfull.
        """

        query_profile = self.GetProfile(query_nid)
        query_profile.useSegment(query_from, query_to)

        sbjct_profile = self.GetProfile(sbjct_nid)
        sbjct_profile.useSegment(sbjct_from, sbjct_to)

        alignator = alignlib.makeFullDP(self.mGop, self.mGep)
        result = alignlib.makeAlignataVector()

        alignator.Align(query_profile, sbjct_profile, result)

        if self.mLogLevel >= 3:
            print "# --> %i vs %i: score=%5.2f, length=%i, numgaps=%i, row_from=%i, row_to=%i, col_from=%i, col_to=%i" %\
                  (query_nid, sbjct_nid,
                   result.getScore(),
                   result.getLength(),
                   result.getNumGaps(),
                   result.getRowFrom(), result.getRowTo(),
                   result.getColFrom(), result.getColTo())
            sys.stdout.flush()

        query_profile.useFullLength()
        sbjct_profile.useFullLength()

        if result.getScore() > self.mMinAlignmentScore:
            return 1, result
        else:
            return 0, result
コード例 #2
0
ファイル: ScopTester.py プロジェクト: BioXiao/cgat
                                 fragment.getColFrom(), fragment.getColTo(),
                                 overlap, xcol_from, xcol_to,
                                 (xcol_to - xcol_from) - (col_to - col_from)) )
            
        return ("0",) * 12
        
##--------------------------------------------------------------------------------------
                
if __name__ == '__main__':

    dbhandle = Pairsdb()
    if not dbhandle.Connect():
	print "Connection failed"
	sys.exit(1)
    
    a = alignlib.makeFullDP( -10.0, -2.0 )
    alignator = Alignator( a )

    x = ScopTesterSequences( dbhandle, alignator )
    
    x.Process()

    if param_alignator == 0:
        a = alignlib.makeFullDP( param_gop, param_gep)

        alignator = Alignator( a )
    if param_entities == 0:
        tester = ScopTesterSequences( dbhandle, alignator )

        tester.mLogLevel = param_loglevel
コード例 #3
0
    def CheckLink(self, query_nid, query_from, query_to, sbjct_nid, sbjct_from,
                  sbjct_to):
        """check, whether link is faithfull.
        """

        query_profile = self.GetProfile(query_nid)
        query_profile.useSegment(query_from, query_to)

        sbjct_profile = self.GetProfile(sbjct_nid)
        sbjct_profile.useSegment(sbjct_from, sbjct_to)

        alignator = alignlib.makeFullDP(self.mGop, self.mGep)
        result = alignlib.makeAlignataVector()

        alignator.Align(query_profile, sbjct_profile, result)

        if result.getLength() == 0:
            query_profile.useFullLength()
            sbjct_profile.useFullLength()
            return 0, result

        if self.mLogLevel >= 3:
            print "# --> %i vs %i: score=%5.2f, length=%i, numgaps=%i, row_from=%i, row_to=%i, col_from=%i, col_to=%i" %\
                  (query_nid, sbjct_nid,
                   result.getScore(),
                   result.getLength(),
                   result.getNumGaps(),
                   result.getRowFrom(), result.getRowTo(),
                   result.getColFrom(), result.getColTo())
            sys.stdout.flush()

        if result.getScore() < self.mMinAlignmentScore:
            query_profile.useFullLength()
            sbjct_profile.useFullLength()
            return 0, result

        if result.getScore() > self.mSafetyThreshold * self.mMinAlignmentScore:
            query_profile.useFullLength()
            sbjct_profile.useFullLength()
            return 1, result

        z_params = alignlib.makeNormalDistributionParameters()
        alignlib.calculateZScoreParameters(z_params, query_profile,
                                           sbjct_profile, alignator,
                                           self.mNumIterationsZScore)
        mean = z_params.getMean()
        stddev = z_params.getStandardDeviation()
        if stddev == 0: stddev = 1

        zscore = (result.getScore() - mean) / stddev

        if self.mLogLevel >= 3:
            print "# --> mean=%f, stdev=%f, zscore=%f" % (mean, stddev, zscore)
            sys.stdout.flush()

        query_profile.useFullLength()
        sbjct_profile.useFullLength()

        if zscore > self.mMinZScore:
            return 1, result
        else:
            return 0, result
コード例 #4
0
def buildMapPdb2Sequence( sequence, filename_pdb, options, pdb_chain = ""):
    """build a map for residue numbers in pdb file to residue numbers on
    a sequence.

    returns the following maps:

    map_structure2seq: mapping of residue numbers between structure and
        sequence. These are mappings that will work if you "renumber" the
        structure.
        
    map_pdb2seq, map_seq2pdb: mapping according to residue numbers in pdb file.
    """

    if not os.path.exists( filename_pdb ):
        return None, None
    
    structure = Scientific.IO.PDB.Structure( filename_pdb )
    
    map_pdb2seq = {}
    map_seq2pdb = {}
    
    for chain in structure.peptide_chains:

        if chain.chain_id == pdb_chain:
            
            ## align pdb sequence to sequence
            map_structure2seq = alignlib.makeAlignataVector()
            alignator = alignlib.makeFullDP( -10.0, -2.0 )

            ## build sequence of pdb file
            structure = ""
            
            for residue in chain.sequence():
                structure += AMINOACIDS[residue]

            ## align reference sequence to sequence of pdb file
            row = alignlib.makeSequence( structure )
            col = alignlib.makeSequence( sequence )
            alignator.Align(row, col, map_structure2seq)

            if options.loglevel >= 3:
                options.stdlog.write( "structure: %s\n" % structure )                
                options.stdlog.write( "sequence : %s\n" % sequence )
                options.stdlog.write( "alignment of structure to sequence:\n" )
                options.stdlog.write( alignlib.writePairAlignment( row, col, map_structure2seq ) + "\n" )
                
            # print alignlib.writeAlignataTable(map_structure2seq)

            residue_number = 0
            
            for residue in chain.residues:

                residue_number += 1
                
                mapped_residue = map_structure2seq.mapRowToCol(residue_number)
                
                if not mapped_residue:
                    if options.loglevel >= 3:
                        options.stdlog.write( "# skipped residue %s=%s %i\n" % (str(residue.number), residue.name, residue_number))
                    continue

                r = str(residue.number)
                map_pdb2seq[r] = mapped_residue
                map_seq2pdb[mapped_residue] = r
                
            return map_structure2seq, map_pdb2seq, map_seq2pdb, residue_number-1, str(chain.residues[0].number), str(chain.residues[-1].number), structure
コード例 #5
0
    dbhandle = Picasso()
    if not dbhandle.Connect():
	print "Connection failed"
	sys.exit(1)

    x = AlignatorBenchmark( dbhandle )

    x.SetTableSources( "picasso_benchmark.scop_sources" )
    x.SetTableAlignments( "picasso_benchmark.scop_alignments" )

    # if a sequence has repeated domains of the same type, only one gets chosen
    statement = "SELECT DISTINCTROW rep_nid, rep_from, rep_to, SUBSTRING(scop_class, 1, 9) " +\
                " FROM nrdb40_scop GROUP BY rep_nid, SUBSTRING(scop_class, 1, 9) "
    
    x.FillSources( statement )

    x.FilterSourcesDegeneracy( 2, 3 )
    x.FilterSources( "SUBSTRING(class,1,3) > 4")

    alignator = alignlib.makeFullDP( -12.0, -2.0 )

    x.SetAlignator( alignator )
    x.FillAlignments()
    





コード例 #6
0
ファイル: ScopTester.py プロジェクト: logust79/cgat-apps
                                 overlap, xcol_from, xcol_to,
                                 (xcol_to - xcol_from) - (col_to - col_from)))

        return ("0", ) * 12


##--------------------------------------------------------------------------------------

if __name__ == '__main__':

    dbhandle = Pairsdb()
    if not dbhandle.Connect():
        print "Connection failed"
        sys.exit(1)

    a = alignlib.makeFullDP(-10.0, -2.0)
    alignator = Alignator(a)

    x = ScopTesterSequences(dbhandle, alignator)

    x.Process()

    if param_alignator == 0:
        a = alignlib.makeFullDP(param_gop, param_gep)

        alignator = Alignator(a)
    if param_entities == 0:
        tester = ScopTesterSequences(dbhandle, alignator)

        tester.mLogLevel = param_loglevel
コード例 #7
0
    def CheckLink( self,
                   query_nid, query_from, query_to,
                   sbjct_nid, sbjct_from, sbjct_to):
        """check, whether link is faithfull.
        """


        query_profile = self.GetProfile( query_nid )
        query_profile.useSegment( query_from, query_to)

        sbjct_profile = self.GetProfile( sbjct_nid )
        sbjct_profile.useSegment( sbjct_from, sbjct_to)        

        alignator = alignlib.makeFullDP( self.mGop, self.mGep )
        result = alignlib.makeAlignataVector()
        
        alignator.Align( query_profile, sbjct_profile, result)
        
        if result.getLength() == 0:
            query_profile.useFullLength()
            sbjct_profile.useFullLength()
            return 0, result
        
        if self.mLogLevel >= 3:
            print "# --> %i vs %i: score=%5.2f, length=%i, numgaps=%i, row_from=%i, row_to=%i, col_from=%i, col_to=%i" %\
                  (query_nid, sbjct_nid,
                   result.getScore(),
                   result.getLength(),
                   result.getNumGaps(),
                   result.getRowFrom(), result.getRowTo(),
                   result.getColFrom(), result.getColTo())
            sys.stdout.flush()

        if result.getScore() < self.mMinAlignmentScore:
            query_profile.useFullLength()
            sbjct_profile.useFullLength()
            return 0, result

        if result.getScore() > self.mSafetyThreshold * self.mMinAlignmentScore:
            query_profile.useFullLength()
            sbjct_profile.useFullLength()
            return 1,result
        
        z_params = alignlib.makeNormalDistributionParameters()
        alignlib.calculateZScoreParameters( z_params,
                                            query_profile,
                                            sbjct_profile,
                                            alignator,
                                            self.mNumIterationsZScore)
        mean   = z_params.getMean()
        stddev = z_params.getStandardDeviation()
        if stddev == 0: stddev = 1
        
        zscore = (result.getScore() - mean) / stddev
        
        if self.mLogLevel >= 3:
            print "# --> mean=%f, stdev=%f, zscore=%f" % (mean, stddev, zscore)
            sys.stdout.flush()
            
        query_profile.useFullLength()
        sbjct_profile.useFullLength()
        
        if zscore > self.mMinZScore:
            return 1,result
        else:
            return 0,result