Example #1
0
def rMap_full(f_in, f_out):
	
	# Database connection parameters
	dbConn = DatabaseConn()
	db = dbConn.databaseConnect()
	cursor = db.cursor()

	gHandler = GeneralHandler(db, cursor)
	rHandler = ReagentHandler(db, cursor)
	seqHandler = SequenceHandler(db, cursor)

	infile = open(f_in, 'r')
	outfile = open(f_out, 'w')
	
	for line in infile.readlines():
		reagentID = line.strip()	# e.g. V123
		
		rID = rHandler.convertReagentToDatabaseID(reagentID)
		seqID = rHandler.findDNASequenceKey(rID)
		
		if seqID:
			mySeq = seqHandler.findSequenceByID(seqID)

                	# Construct a Seq object readable by BioPython:
			bioSeq = Seq(mySeq)
			fSeq = FormattedSeq(bioSeq)             # default linear = TRUE

			analysis = Analysis(AllEnzymes, fSeq)   # linear = true
			result = analysis.full()
			header = "==============================================\nRestriction analysis for " + reagentID + "\n==============================================\n"
			analysis.print_that(title=header+'\n\n')
Example #2
0
def rMap_full(f_in, f_out):

    # Database connection parameters
    dbConn = DatabaseConn()
    db = dbConn.databaseConnect()
    cursor = db.cursor()

    gHandler = GeneralHandler(db, cursor)
    rHandler = ReagentHandler(db, cursor)
    seqHandler = SequenceHandler(db, cursor)

    infile = open(f_in, 'r')
    outfile = open(f_out, 'w')

    for line in infile.readlines():
        reagentID = line.strip()  # e.g. V123

        rID = rHandler.convertReagentToDatabaseID(reagentID)
        seqID = rHandler.findDNASequenceKey(rID)

        if seqID:
            mySeq = seqHandler.findSequenceByID(seqID)

            # Construct a Seq object readable by BioPython:
            bioSeq = Seq(mySeq)
            fSeq = FormattedSeq(bioSeq)  # default linear = TRUE

            analysis = Analysis(AllEnzymes, fSeq)  # linear = true
            result = analysis.full()
            header = "==============================================\nRestriction analysis for " + reagentID + "\n==============================================\n"
            analysis.print_that(title=header + '\n\n')
Example #3
0
def open_dataset() -> dict:
    """
    打开脚本文件
    :return: dict response 内容
    """
    if request.method == "GET":
        file_path = request.args.get("path", "")

        if not os.path.exists(file_path):
            return {"code": 0, "msg": "打开文件失败!", "data": {"msg": "当前路径不存在文件,请检查文件路径!"}}

        try:
            print(file_path)
            with open(file_path, "r", encoding="utf-8") as file:
                dataset = [line for line in jsonlines.Reader(file)]
                data_handler = SequenceHandler()
                data_handler.set_dataset(dataset)
                data_handler.file_path = file_path

            uid = str(uuid4())
            dataset_dict[uid] = data_handler

            feedback = {
                "code": 1,
                "msg": "打开文件成功!",
                "data": {
                    "length": len(dataset),
                    "uid": uid
                }
            }
        except Exception as error:
            feedback = {
                "code": 0,
                "msg": "打开文件失败!",
                "data": {
                    "msg": str(error)
                }
            }
    else:
        feedback = {"code": 0, "msg": "请求方法有误!", "data": {}}
    return feedback
Example #4
0
def rMap_specific(f_in, f_out, enz_list):
	
	# Database connection parameters
	dbConn = DatabaseConn()
	db = dbConn.databaseConnect()
	cursor = db.cursor()
	
	gHandler = GeneralHandler(db, cursor)
	rHandler = ReagentHandler(db, cursor)
	seqHandler = SequenceHandler(db, cursor)

	infile = open(f_in, 'r')
	outfile = open(f_out, 'w')	

	for line in infile.readlines():
		reagentID = line.strip()	# e.g. V123
		rID = rHandler.convertReagentToDatabaseID(reagentID)
		seqID = rHandler.findDNASequenceKey(rID)

		if seqID:
			mySeq = seqHandler.findSequenceByID(seqID)
			
			# Construct a Seq object readable by BioPython:
			bioSeq = Seq(mySeq)
			fSeq = FormattedSeq(bioSeq, linear=False)		# linear = FALSE, we're dealing w/ VECTORS

			analysis = Analysis(enz_list, fSeq, linear=False)  	# linear = FALSE again for VECTORS
			result = analysis.full()

			outfile.write(reagentID + ": " + '\n')

			# calculate bandwidths
			allSites = []
			
			for enz in result.keys():
				sites = result[enz]
				
				if len(allSites) == 0:
					allSites = sites
				else:
					# concatenate
					for s in sites:
						allSites.append(s)

			allSites.sort()

			if len(allSites) > 0:
				
				# calculate distances between sites
				bandSizes = []
				
				i = 1
				
				while i < len(allSites):
					tmpLen = allSites[i] - allSites[i-1]
					bandSizes.append(tmpLen)
					i += 1
				
				# last band
				tmpLen = len(mySeq) - allSites[i-1] + allSites[0]
				bandSizes.append(tmpLen)
				
				bandSizes.sort()
				
				outfile.write(`bandSizes` + '\n')

			outfile.write('\n')
			
	infile.close()
	outfile.close()
	cursor.close()
	db.close()
Example #5
0
def rMap_specific(f_in, f_out, enz_list):

    # Database connection parameters
    dbConn = DatabaseConn()
    db = dbConn.databaseConnect()
    cursor = db.cursor()

    gHandler = GeneralHandler(db, cursor)
    rHandler = ReagentHandler(db, cursor)
    seqHandler = SequenceHandler(db, cursor)

    infile = open(f_in, 'r')
    outfile = open(f_out, 'w')

    for line in infile.readlines():
        reagentID = line.strip()  # e.g. V123
        rID = rHandler.convertReagentToDatabaseID(reagentID)
        seqID = rHandler.findDNASequenceKey(rID)

        if seqID:
            mySeq = seqHandler.findSequenceByID(seqID)

            # Construct a Seq object readable by BioPython:
            bioSeq = Seq(mySeq)
            fSeq = FormattedSeq(
                bioSeq,
                linear=False)  # linear = FALSE, we're dealing w/ VECTORS

            analysis = Analysis(
                enz_list, fSeq,
                linear=False)  # linear = FALSE again for VECTORS
            result = analysis.full()

            outfile.write(reagentID + ": " + '\n')

            # calculate bandwidths
            allSites = []

            for enz in result.keys():
                sites = result[enz]

                if len(allSites) == 0:
                    allSites = sites
                else:
                    # concatenate
                    for s in sites:
                        allSites.append(s)

            allSites.sort()

            if len(allSites) > 0:

                # calculate distances between sites
                bandSizes = []

                i = 1

                while i < len(allSites):
                    tmpLen = allSites[i] - allSites[i - 1]
                    bandSizes.append(tmpLen)
                    i += 1

                # last band
                tmpLen = len(mySeq) - allSites[i - 1] + allSites[0]
                bandSizes.append(tmpLen)

                bandSizes.sort()

                outfile.write( ` bandSizes ` + '\n')

            outfile.write('\n')

    infile.close()
    outfile.close()
    cursor.close()
    db.close()