pyfishmanager.database module

class pyfishmanager.database.database(name)[source]

Bases: object

Main database class. Basically stores a list of lines objects and provides methods for printout/filtering and manipultating line objects

checkNumberOfLineEntries()[source]
defaultDict()[source]

Creates default dictionary for stock list I/O.

Returns:Dictionary translating from stocklist to database.
Return type:dict
extractLineProperty(r, prop)[source]

Extracts a single property from list of lines.

Parameters:
  • r (list) – List of lines.
  • prop (int) – property to be extracted.
Returns:

List of values of property of all lines.

Return type:

list

filterDead(r)[source]

Filters out dead lines.

Parameters:r (list) – List of lines.
Returns:Filtered list.
Return type:list
filterNotGenotyped(r)[source]

Filters out non-genotyped lines.

Parameters:r (list) – List of lines.
Returns:Filtered list.
Return type:list
getAllContainGenotype(genotype)[source]

Returns all lines that contains given genotype.

Parameters:genotype (str) – Genotype that is looked for.
Returns:List of lines containing genotype.
Return type:list
getAllGenotypes()[source]

Returns all different genotypes in the database.

Returns:List of genotypes.
Return type:list
getAllOfGenotype(genotype)[source]

Returns all lines that have exatly given genotype.

Parameters:genotype (str) – Genotype that is looked for.
Returns:List of lines having genotype.
Return type:list
getDatabaseStats(onlyGenotyped=True)[source]

Computes statistics of database.

Keyword Arguments:
 onlyGenotyped (bool) – Only check genotyped lines.
Returns:statistics per line.
Return type:dict
getNumberOfFishesOfGenotype(genotype, onlyGenotyped=True)[source]

Returns number of fishes of given genotype.

Parameters:genotype (str) – Genotype of fish line
Keyword Arguments:
 onlyGenotyped (bool) – Only check genotyped lines.
Returns:Number of fish.
Return type:int
getNumberOfLineEntries(line)[source]
makeCSVHeader()[source]

Checks line object properties of first line and uses them to build a header.

Returns:Header
Return type:list
printCriticalLines(onlyGenotyped=True, nCrit=60)[source]

Prints all critical fish lines as table.

Keyword Arguments:
 
  • onlyGenotyped (bool) – Only check genotyped lines.
  • nCrit (int) – Number of fish that is considered to be critical.
printDatabase()[source]

Prints out complete database in tabular form.

printDatabaseStats(onlyGenotyped=True)[source]

Prints statistics of database as table.

Keyword Arguments:
 onlyGenotyped (bool) – Only check genotyped lines.
readStockList(fn)[source]

Reads in stock list from csv file

Parameters:fn (str) – Filename of stock list.
Returns:List of lines in stock list.
Return type:list
readStockListHeader(fn, irow=0, delimiter=';', quotechar='|')[source]

Reads in header of stock list.

Parameters:

fn (str) – Filename of stock list.

Keyword Arguments:
 
  • irow (int) – Row of header
  • delimiter (str) – Delimiter that is used in csv sheet.
  • quotechar (str) – Quotechar that is used in csv sheet.
Returns:

Header.

Return type:

list

saveToCSV(fn=None, delimiter=', ')[source]

Saves database to csv file.

Keyword Arguments:
 
  • fn (str) – filename
  • delimiter (str) – Delimiter used in csv file
Returns:

True if success, False else

Return type:

bool

saveToPickle(fn=None)[source]

Saves database to pickle file.

Keyword Arguments:
 fn (str) – filename
Returns:True
Return type:bool
updateAllLineAttr(attr, prop, lines=None)[source]

Updates attribute in list of lines. If lines is not given, will set attribute for all lines.

Parameters:
  • attr (str) – Attribute to be set
  • prop (any) – Value to be set
Keyword Arguments:
 

lines (list) – List of lines.

Returns:

List of updates lines.

Return type:

list

writeLinesToCSV(csvFile)[source]

Write all lines to csv file.

Parameters:csvFile (file) – csv file object
Returns:the csv file object
Return type:file