예제 #1
0
def insert_phenotypes_from_file(conn, phenotypeFile, populationID):
    """Inserts phenotypes into database

  This function inserts phenotypes from a file into a database

  :param conn: psycopg2 connection
  :type conn: connection object
  :param phenotypeFile: absolute path to input file
  :type phenotypeFile: string
  :param populationID: :ref:`population_id <population_class>`
  :type populationID: integer
  :return: list of phenotype_id
  :rtype: list of integers
  """
    maize282popID = find.find_population(conn, 'Maize282')
    # Read through just the first column of the CSV, ignoring any column
    phenotypeRawData = pd.read_csv(phenotypeFile, index_col=0)
    insertedPhenoIDs = []
    for key, value in tqdm(phenotypeRawData.iteritems(), desc="Phenotypes"):
        # print("***********KEY**************:")
        # print(key)
        traitID = find.find_trait(conn, key)
        for line_name, traitval in tqdm(value.iteritems(), desc="Traits"):
            lineID = find.find_line(conn, line_name, maize282popID)
            if lineID is None:
                newline = line(line_name, maize282popID)
                lineID = insert_line(conn, newline)
            pheno = phenotype(lineID, traitID, traitval)
            # print(pheno)
            insertedPhenoID = insert_phenotype(conn, pheno)
            insertedPhenoIDs.append(insertedPhenoID)
    return insertedPhenoIDs
예제 #2
0
파일: insert.py 프로젝트: mwohl/BaxDB
def insert_lines_from_file(conn, lineFile, populationID):
    linelist = ph.parse_lines_from_file(lineFile)
    insertedLineIDs = []
    for linename in linelist:
        lineobj = line(linename, populationID)
        insertedLineID = insert_line(conn, lineobj)
        insertedLineIDs.append(insertedLineID)
    return insertedLineIDs
예제 #3
0
파일: insert.py 프로젝트: mwohl/BaxDB
def insert_phenotypes_from_file(conn, phenotypeFile, populationID):
    phenotypeRawData = pd.read_csv(phenotypeFile, index_col=0)
    insertedPhenoIDs = []
    for key, value in phenotypeRawData.iteritems():
        print("***********KEY**************:")
        print key
        traitID = find_trait(conn, key)
        for index, traitval in value.iteritems():
            print("index:")
            print(index)
            lineID = find_line(conn, index, maize282popID)
            if lineID is None:
                newline = line(index, maize282popID)
                lineID = insert_line(conn, newline)
            print("trait value:")
            print(traitval)
            pheno = phenotype(lineID, traitID, traitval)
            insertedPhenoID = insert_phenotype(conn, pheno)
            insertedPhenoIDs.append(insertedPhenoID)
    return insertedPhenoIDs
예제 #4
0
def insert_lines_from_file(conn, lineFile, populationID):
    """Inserts lines into database from a file

  This function inserts a lines into a database from a file

  :param conn: psycopg2 connection
  :type conn: connection object
  :param lineFile: absolute path to input file
  :type lineFile: string
  :param populationID: :ref:`population <population_class>`
  :type populationID: integer
  :return: list of population_id
  :rtype: list of integers
  """
    linelist = ph.parse_lines_from_file(lineFile)
    insertedLineIDs = []
    for linename in tqdm(linelist, desc="Lines"):
        lineobj = line(linename, populationID)
        insertedLineID = insert_line(conn, lineobj)
        insertedLineIDs.append(insertedLineID)
    return insertedLineIDs
예제 #5
0
def new_line():
    data = request.get_json()
    print 'adding new line to day', request.get_json()['day_id'], 'line', request.get_json()['line_id']
    now = datetime.datetime.now()
    date = '%s/%s/%s' % (now.month, now.day, now.year)
    d = day.query.get(int(data['day_id']))
    if (current_user.is_authenticated and current_user.id == d.user_id): 
        l = line(text='<br>', 
                 date=date, 
                 date_complete=date, 
                 check=False, 
                 important=False, 
                 parent_id=data['line_id'], 
                 user_id=d.user_id, 
                 book_id=d.book_id, 
                 day_id=d.id, 
                 shape=0)
        db.session.add(l)     
        db.session.commit()
        print 'commited session'
        return jsonify(id = l.id)
    return jsonify(id = 0)
예제 #6
0
  print("[ INSERT ]\t(%s)\t%s" % (insertedSpeciesID, str(soybeanSpecies)))
  mySpecies = species('maize', 'Zea mays', None, None)
  insertedSpeciesID = insert.insert_species(conn, mySpecies)
  print("[ INSERT ]\t(%s)\t%s" % (insertedSpeciesID, str(mySpecies)))
  maizeSpeciesID = find.find_species(conn, 'maize')
  print("[ FIND ]\t(%s)\t%s" % (maizeSpeciesID, '< species: maize >'))

  # ADD A HARD-CODED POPULATION TO DB USING insert_population()
  myPopulation = population('Maize282', maizeSpeciesID)
  insertedPopulationID = insert.insert_population(conn, myPopulation)
  print("[ INSERT ]\t(%s)\t%s" % (insertedPopulationID, str(myPopulation)))
  maize282popID = find.find_population(conn, 'Maize282')
  print("[ FIND ]\t(%s)\t%s" % (maize282popID, '< population: Maize282 >'))

  # ADD A HARD-CODED LINE TO DB USING insert_line()
  myLine = line(line_name='282set_B73', line_population=maize282popID)
  insertedLineID = insert.insert_line(conn, myLine)
  print("[ INSERT ]\t(%s)\t%s" % (insertedLineID, str(myLine)))
  B73lineID = find.find_line(conn, '282set_B73', maize282popID)
  print("[ FIND ]\t(%s)\t%s" % (B73lineID, '< line: Maize282 >'))

  # ADD NEW HARD-CODED GENOTYPE_VERSION TO DB
  myGenotypeVersion = genotype_version(genotype_version_name='B73 RefGen_v4_AGPv4_Maize282',
                                       genotype_version=315, reference_genome=B73lineID, genotype_version_population=maize282popID)
  B73_agpv4_maize282_versionID = insert.insert_genotype_version(conn, myGenotypeVersion)
  print("[ INSERT ]\t(%s)\t%s" % (B73_agpv4_maize282_versionID, str(myGenotypeVersion)))

  # ADD ALL CHROMOSOMES FOR A SPECIES TO DB
  insertedChromosomeIDs = insert.insert_all_chromosomes_for_species(conn, 10, maizeSpeciesID)
  print("[ INSERT ]\t%s\t%s" % (insertedChromosomeIDs, '\t10 (sID: %s)' % maizeSpeciesID))
예제 #7
0
            check=False,
            important=False,
            date="null",
            parent_id=2,
            text="the '+' adds a child line to the current point",
        ),
    ],
]
for points in liners:
    l = points[0]
    lines.append(
        line(text=l['text'],
             date=b.date,
             date_complete=b.date,
             check=l['check'],
             important=l['important'],
             parent_id=0,
             user_id=u.id,
             book_id=b.id,
             day_id=d['id'],
             shape=l['shape']))
    db.session.add(lines[-1])
    db.session.commit()
    pid = lines[-1].id
    for point in points[1:]:
        l = point
        lines.append(
            line(text=l['text'],
                 date=b.date,
                 date_complete=b.date,
                 check=l['check'],
                 important=l['important'],
 def __init__(self):
     """Creates the lines object"""
     self.red_line = line("red")
     self.green_line = line("green")
     self.blue_line = line("blue")